GithubHelp home page GithubHelp logo

therocketforever / dm-aggregates Goto Github PK

View Code? Open in Web Editor NEW

This project forked from datamapper/dm-aggregates

0.0 2.0 0.0 292 KB

DataMapper plugin providing support for aggregates on collections

Home Page: http://datamapper.org/

License: MIT License

dm-aggregates's Introduction

dm-aggregates

DataMapper plugin providing support for aggregates, functions on collections and datasets.

It provides the following functions:

count

Count results (given the conditions)

Friend.count # returns count of all friends
Friend.count(:age.gt => 18) # returns count of all friends older then 18
Friend.count(:conditions => [ 'gender = ?', 'female' ]) # returns count of all your female friends
Friend.count(:address) # returns count of all friends with an address (NULL values are not included)
Friend.count(:address, :age.gt => 18) # returns count of all friends with an address that are older then 18
Friend.count(:address, :conditions => [ 'gender = ?', 'female' ]) # returns count of all your female friends with an address

min

Get the lowest value of a property

Friend.min(:age) # returns the age of the youngest friend
Friend.min(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the age of the youngest female friends

max

Get the highest value of a property

Friend.max(:age) # returns the age of the oldest friend
Friend.max(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the age of the oldest female friends

avg

Get the average value of a property

Friend.avg(:age) # returns the average age of friends
Friend.avg(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the average age of the female friends

sum

Get the total value of a property

Friend.sum(:age) # returns total age of all friends
Friend.sum(:age, :conditions => [ 'gender = ?', 'female' ]) # returns the total age of all female friends

dm-aggregates's People

Contributors

dkubb avatar snusnu avatar solnic avatar myabc avatar bernerdschaefer avatar namelessjon avatar postmodern avatar foysavas avatar michaelklishin avatar somebee avatar gix avatar sam avatar dbussink avatar joe avatar cypher avatar paul avatar bobbus avatar

Watchers

Don Wei avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.