Wednesday 18 September 2013

How to do soring base on field of document?

How to do soring base on field of document?

Let's say i have a lot of data with this pattern in mongoDB:
db.customer.find()
{'_id':ObjectId('someId'),'customer':'brendon','address':'singapore','activity':[{'id':someId,'detail':'approaching'},{'id':someId,'detail':'explaining'},{'id':someId,'detail':'deal'}]}
this data means i have customer collection and each customer has array of
activity,
now, for all customer i want to do paging/sorting about 10 document per page.
and
how to do this in mongoDB.
in relational sql this is represented with:
customer (custId, name, address)
activity (actId, detail, custId)
select * from activity
left join customer
limit 10,0

No comments:

Post a Comment