- 博客(5)
- 收藏
- 关注
原创 Mongoose find
Mongodb findmodel: Document查询单个字段1. 未删除的Document.find({deleted: {$ne: true} 或者 deleted: false})2. 存在的DocumentDocument.find({title:{$exists:true})Document.find({title:{$nin:[null,undefined,...
2018-11-14 18:33:07
1077
原创 Array reduce && sort
数组中每个值出现次数排序,并截取前几位MDN Array.prototype.reduce()function _sort(userIds, count = 1) { let obj = userIds.reduce((o, k) => { k in o ? o[k]++ : (o[k] = 1); return o; }, {});...
2018-11-14 18:21:29
104
原创 Array reduce
Array.prototype.reduce()按数组中某个值进行分组let questions = [{ group: 'group1', title: 'question content 1'}, { group: 'group1', title: 'question content 2'}, { group: 'group1', t...
2018-11-14 17:33:27
504
原创 MongoDB aggregate
聚合查询// aggregate里的各种查询可以组合使用// 聚合查询Entry.aggregate([ { // $match 筛选,和find查询条件一致 $match: { $or: [{'showcase.type': CONSTANT.contestType.STANDARD}], 'sho...
2018-09-03 10:50:06
954
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人