Go教程

mongodb 随笔

本文主要是介绍mongodb 随笔,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
  • 报错:db.collection.find({}, { "record" : 0 , "index.teacher_base_name" : 1 , "_id" : 0})
queryObject.fields().exclude("_id");
queryObject.fields().exclude("record");
queryObject.fields().include("index." + indexName);
  • mongodb内容过大
/usr/bin/mongod --config /etc/mongod.conf --fork --wiredTigerCacheSizeGB 1
  • Aggregation.group
db.teacher_record.aggregate([{$group: {
  _id: "$cardId",
  approvalStatus: {
    $first: "$approvalStatus"
  }
}}])

{
  _id: {cardId:"$cardId", tenantId:"$tenantId"},
  approvalStatus: {
    $push: "$approvalStatus"
  }
}
Aggregation.group("cardId", "tenantId")
	.first("operationUser.userName").as("operationUser.userName")
	.first("operationUser.unitName").as("operationUser.unitName")
	.first("approvalTime").as("approvalTime")
	.sum(ConditionalOperators.when(Criteria.where("approvalStatus").is(0)).then(1).otherwise(0)).as("pendingNum")
	.push("recordId").as("recordIds")
这篇关于mongodb 随笔的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!