随笔分类 - mongodb笔记
摘要:let photoId = mongoose.Types.ObjectId(`${virtual.productId[0]}`) await model.photo.findByIdAndUpdate(photoId, { $set: { photto: photo } }, { upsert: t
阅读全文
摘要:1."$gt" 、"$gte"、 "$lt"、 "$lte"、"null查询"、"$all"、"$size"、"$in"、"$nin"、"$and"、"$nor"、"$not"、"$or"、"$exists"、"$mod"、"$regex"、"$where"、
阅读全文
摘要:一、$group 进行分组 1、每个职位的雇员人数: db.getCollection('emp').aggregate( [ {'$group':{ ‘_id’:'$job', job_count:{'$sum':1} } } ] ) 2、每个职位的总工资 db.getCollection('em
阅读全文
摘要:1.$inc: 对数字字段内容进行修改 db.getCollection('student').update( {'age':19}, {$inc:{'score':-20}} ) 2.$set :对字段内容进行修改 3.$unset :对字段内容进行删除 db.getCollection('stu
阅读全文
摘要:db.getCollections('students').update({},{$set:{}},{upsert:false,multi:false}) 更新单行,upsert为true时,更新不存在的数据,即为添加数据 db.getCollections('students').update({
阅读全文
摘要:1、查询课程中包含math,chinese的课程 db.getCollection('student').find( { course:{$all:['math','chinese']} } ).pretty() 2.查询第二门课程是数学 db.getCollection('student').fi
阅读全文
摘要:var user = db.getCollection('user') //user.find({},{_id:0}).pretty().count() user.find({age:{$gte:25,$lt:70}},{_id:-1}) .sort({age:-1}) .skip(2).limit
阅读全文

浙公网安备 33010602011771号