Querys advanced multiple similar documents

10 views
Skip to first unread message

Alejo Mext

unread,
Sep 20, 2013, 12:31:45 AM9/20/13
to mongoo...@googlegroups.com
I need to make a query that a change is repeated in several documents. But I just want to leave me one of those documents. But I can not do 'FindOne', why should I bring more documents with those same characteristics. As such querys ago?

That means, I have this in the collection

{ x : ObjectId(1),
y : [ ObjectId(2) ], z : "My string ...", w : ISODate("2013-09-19T16:45:13.573Z") }
{ x : ObjectId(2), y : [ ObjectId(3), ObjectId(1) ], z : "My string", w : ISODate("2013-09-18T00:57:41.204Z")}
{ x : ObjectId(3), y : [ ObjectId(4), ObjectId(2) ], z : "My string", w :ISODate("2013-09-18T00:57:41.204Z") }
{ x : ObjectId(4), y : [ ObjectId(3) ], z : "My string", w : ISODate("2013-09-19T16:45:13.573Z") }
{ x : ObjectId(1), y : [ ObjectId(2), ObjectId(3) ], z : "My string", w : ISODate("2013-09-19T16:45:13.573Z") }
{ x : ObjectId(4), y : [ ObjectId(3) ], z : "My string", w : ISODate("2013-09-19T16:45:13.573Z") }
{ x : ObjectId(1), y : [ ObjectId(2), ObjectId(3) ], z : "My string", w : ISODate("2013-09-19T16:45:13.573Z") }

Now I want to go so

{ x : ObjectId(1),
y : [ ObjectId(2) ], z : "My string ...", w : ISODate("2013-09-19T16:45:13.573Z") }
{ x : ObjectId(2), y : [ ObjectId(3), ObjectId(1) ], z : "My string", w : ISODate("2013-09-18T00:57:41.204Z")}
{ x : ObjectId(3), y : [ ObjectId(4), ObjectId(2) ], z : "My string", w :ISODate("2013-09-18T00:57:41.204Z") }
{ x : ObjectId(4), y : [ ObjectId(3) ], z : "My string", w : ISODate("2013-09-19T16:45:13.573Z") }

Data not know
  • The content of the string --> z
  • The Id --> x
  • With the date is organized or making a sort

Data if

  • I have an Id corresponding to y
  • And I have a maximum number of documents or a limit is 100

Anyone know how that kind of querys????? Or solve this problem????

Remember that the collection has been enlarged and at all times should give that. the query!

Reply all
Reply to author
Forward
0 new messages