MongDB Query with DBRef
General syntax for mongodb find query is
db.collection.find({<here comes the find conditin>})
for example : if i want to find a student with email address student@email.com , query will be like
db.students.find({"email":"student@email.com"})
where students is a collections.
Now let us say this student belongs to a certain group and we want to find all students of the group to which the said student belongs. We will be using the DBRef for that group, following will be our query
db.students.find({group:DBRef(" groups", ObjectId(" 52a852a844aeb67db4a3518b"))}). pretty()
this query will finds all student who belong to group with object id = ObjectId(" 52a852a844aeb67db4a3518b")
General syntax for mongodb find query is
db.collection.find({<here comes the find conditin>})
for example : if i want to find a student with email address student@email.com , query will be like
db.students.find({"email":"student@email.com"})
where students is a collections.
Now let us say this student belongs to a certain group and we want to find all students of the group to which the said student belongs. We will be using the DBRef for that group, following will be our query
db.students.find({group:DBRef("
this query will finds all student who belong to group with object id = ObjectId("
No comments:
Post a Comment