Announcement Announcement Module
Collapse
No announcement yet.
MongoDB Criteria.all Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoDB Criteria.all

    In mongo console I have:

    Code:
    > db.test.find({})
    { "_id" : ObjectId("515afcfedba6a529520becfa"), "array" : [ { "key" : "one", "value" : 1 }, { "key" : "two", "value" : 2 } ] }
    { "_id" : ObjectId("515b0e48dba6a529520becfd"), "array" : [ { "key" : "one", "value" : 1 }, { "key" : "two", "value" : 2 }, {"key" :"three", "value" : 3 } ] }
    
    
    > db.test.find({array: {$all:[{key:'one', value:1}, {key:'two',value:2}]}});
    { "_id" : ObjectId("515afcfedba6a529520becfa"), "array" : [ { "key" : "one", "value" : 1 }, { "key" : "two", "value" : 2 } ] }
    { "_id" : ObjectId("515b0e48dba6a529520becfd"), "array" : [ { "key" : "one", "value" : 1 }, { "key" : "two", "value" : 2 }, {"key" :"three", "value" : 3 } ] }
    
    > db.test.find({_id:ObjectId("515afcfedba6a529520becfa"), array: {$all:[{key:'one', value:1}, {key:'two',value:2}]}});
    { "_id" : ObjectId("515afcfedba6a529520becfa"), "array" : [ { "key" : "one", "value" : 1 }, { "key" : "two", "value" : 2 } ] }
    How do I write the second and third query using: org.springframework.data.mongodb.core.query.Criter ia ?

  • #2
    All options are available in the Criteria class [0]. Is there anything not working for you?

    [0] http://static.springsource.org/sprin.../Criteria.html

    Comment

    Working...
    X