Grails 2.2.2 + MongoDB 1.3.0 = How to use withCriteria ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 2.2.2 + MongoDB 1.3.0 = How to use withCriteria ?

Konstantyn Smirnov
Hi all

I'm having a domain-class mapped by mongo:

class Points {
  int value
  long userId
}

now I try to get the sum of all values for a single user:

def userSum = Points.withCriteria{
  projections{ sum 'value' }
  eq 'userId', userId
}//.sum() -> expected result

but I'm getting the arrays of value's [ 1, 3, 3 ,5...] instead of the sum.

Can the Mongo GORM handle such a simple case or shall I go for low-level mongo API?

TIA,
Konstantyn
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.2.2 + MongoDB 1.3.0 = How to use withCriteria ?

Graeme Rocher-2
Seems sum is not implemented, raise a JIRA feature request, in the meantime yes you can just use the low-level API


On Wed, Jun 26, 2013 at 3:35 PM, Konstantyn Smirnov <[hidden email]> wrote:
Hi all

I'm having a domain-class mapped by mongo:

class Points {
  int value
  long userId
}

now I try to get the sum of all values for a single user:

def userSum = Points.withCriteria{
  projections{ sum 'value' }
  eq 'userId', userId
}//.sum() -> expected result

but I'm getting the arrays of value's [ 1, 3, 3 ,5...] instead of the sum.

Can the Mongo GORM handle such a simple case or shall I go for low-level
mongo API?

TIA,
Konstantyn




--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-2-2-MongoDB-1-3-0-How-to-use-withCriteria-tp4646125.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.2.2 + MongoDB 1.3.0 = How to use withCriteria ?

Konstantyn Smirnov
done!

do you have an example on how to use the aggregation in groovy?

TIA
Reply | Threaded
Open this post in threaded view
|

Re: Grails 2.2.2 + MongoDB 1.3.0 = How to use withCriteria ?

Graeme Rocher-2


On Thu, Jun 27, 2013 at 12:07 PM, Konstantyn Smirnov <[hidden email]> wrote:
done! <http://jira.grails.org/browse/GPMONGODB-305>

do you have an example on how to use the aggregation in groovy?

TIA



--
View this message in context: http://grails.1312388.n4.nabble.com/Grails-2-2-2-MongoDB-1-3-0-How-to-use-withCriteria-tp4646125p4646145.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Graeme Rocher
Grails Project Lead
SpringSource