- 博客(5)
- 收藏
- 关注
原创 Mongoose find
Mongodb find model: Document 查询单个字段 1. 未删除的 Document.find({deleted: {$ne: true} 或者 deleted: false}) 2. 存在的Document Document.find({title:{$exists:true}) Document.find({title:{$nin:[null,undefined,...
2018-11-14 18:33:07
1114
原创 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
137
原创 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
550
原创 MongoDB aggregate
聚合查询 // aggregate里的各种查询可以组合使用 // 聚合查询 Entry.aggregate([ { // $match 筛选,和find查询条件一致 $match: { $or: [{'showcase.type': CONSTANT.contestType.STANDARD}], 'sho...
2018-09-03 10:50:06
1024
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人