Mongodb is not suitable for multi-table queries. Its table structure design ideas are completely different from SQL databases. It is recommended to become more familiar with mongodb’s table structure design to avoid multi-table queries.
DBRef method association, for example: Table one one, table two two, db.one.insert({name:"Flying Fox"}) o = db.one.find({name:"Flying Fox"})[0 ] db.two.insert({"title":"Associated one"},one:[new DBRef('one',o._id)]) db.two.find({title:"Hello China!" })[0].one[0].fetch() Use skip and limit to perform paging query, for example: db.two.find().sort({"name":1}).skip(10). limit(10);
There is a lot of information online, the key ones are DBRef, sort, skip, limit!
Mongodb is not suitable for multi-table queries. Its table structure design ideas are completely different from SQL databases. It is recommended to become more familiar with mongodb’s table structure design to avoid multi-table queries.
DBRef method association, for example:
Table one one, table two two,
db.one.insert({name:"Flying Fox"})
o = db.one.find({name:"Flying Fox"})[0 ]
db.two.insert({"title":"Associated one"},one:[new DBRef('one',o._id)])
db.two.find({title:"Hello China!" })[0].one[0].fetch()
Use skip and limit to perform paging query, for example:
db.two.find().sort({"name":1}).skip(10). limit(10);
There is a lot of information online, the key ones are DBRef, sort, skip, limit!