数据库
首页 > 数据库> > mongodb 随笔

mongodb 随笔

作者:互联网

queryObject.fields().exclude("_id");
queryObject.fields().exclude("record");
queryObject.fields().include("index." + indexName);
/usr/bin/mongod --config /etc/mongod.conf --fork --wiredTigerCacheSizeGB 1
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")

标签:group,approvalStatus,mongodb,first,cardId,随笔,id,operationUser
来源: https://www.cnblogs.com/JOKI/p/15129884.html