Open uniquejava opened 6 years ago
一句话将{email:'iam'}
改成{email: /^iam/}
即可.
详见: https://stackoverflow.com/questions/3305561/how-to-query-mongodb-with-like
query['arrayname.somekey'] = {"$in": [new RegExp(query[x], 'i')]};
skip(0).limit(10)
let query = {email: /^iam/};
let page = 2,
limit = 50;
Student.count(query,function(err,count){
Student.find(query, null, {
sort: {
name: 1
}
}).skip(page > 0 ? ((page - 1) * limit) : 0).limit(limit).exec(function(err, docs) {
if (err)
res.status(500).json(err);
else
res.json({
"total": count,
"data": docs
});
});
});
详见: https://stackoverflow.com/questions/5539955/how-to-paginate-with-mongoose-in-node-js
https://stackoverflow.com/questions/25507866/how-can-i-use-a-cursor-foreach-in-mongodb-using-node-js
https://stackoverflow.com/questions/3974985/update-mongodb-field-using-value-of-another-field
https://stackoverflow.com/questions/3788256/mongodb-updating-documents-using-data-from-the-same-document
https://docs.mongodb.com/manual/reference/sql-comparison/
https://docs.mongodb.com/manual/reference/sql-aggregation-comparison/
查询: https://docs.mongodb.com/manual/tutorial/query-documents/
self join left join group by having order by distinct sum average update delete array operations create index drop index create table drop table row_number() over partition by
以下所有函数所有参数所有选项实操 mapReduce aggregate lookup
分页