草庐IT

set_null

全部标签

node.js - Mongoose - 带有 $set 标志的 findOneAndUpdate

考虑这个命令:WorkPlan.findOneAndUpdate({_id:req.params.id},updateObj,function(err){...})与此相对:WorkPlan.findOneAndUpdate({_id:req.params.id},{'$set':updateObj},function(err){...})在开发我的项目时,我惊讶地发现第一个命令的结果与第二个命令的结果相同:updateObj被合并到数据库中的现有记录中,即使在第一种情况下应该更换它。这是mongoose/mongodb中的错误还是我做错了什么?如何在更新时替换对象而不是合并它?我正在

Node.js:Mongoose initializeUnorderedBulk 返回 null

不久前,我设法编写了一种方法,可以将许多信息批量更新插入到我的数据库中。现在我正在尝试做的是一种清除同一数据库和表上的旧记录的方法。raidSchema.statics.bulkUpsert=function(raids,callback){varbulk=Raid.collection.initializeUnorderedBulkOp();for(vari=0;i这非常有效。然后我这样做了,希望它能清除我不再需要的旧记录:raidSchema.statics.cleanOldRaids=function(callback){vardate=newDate();date.setMin

python - 为什么 DuplicateKeyError : E11000 duplicate key error index: test. test.$notification_1 dup key: { : null }

我像这样创建唯一索引:self.db_database[co_name].ensure_index([('src_md5',-1),('src_time',-1),('src_size',-1)],unique=True)self.db_database[co_name].ensure_index(('notification'),unique=True)self.db_database[co_name].ensure_index(('version'),unique=True)`在插入之前我创建一条记录如下:self.db_database[co_name].insert({"not

mongodb - Mongo 查询 - 如果数据为 0 或 null,则返回文档

我有以下格式的数据:{"__v":0,"_id":ObjectId("12367687"),"xyzId":"ADV_ID","date":ISODate("2013-08-19T10:58:21.473Z"),"gId":"987654","type":"checks"}对于上述数据,我必须使用“created_on”字段绘制每日、每周、每月和每年数据的图表,并计算“type”字段。我有以下部分有效的查询。db.trackads.aggregate({$match:{"gId":"987654",type:'checks'}},{$group:{_id:{"day":{"$week"

java - 通过示例在 MongoRepository 查询中包含 Null 检查

我正在尝试使用以下方法使用MongoRepository从集合中查找所有符合特定搜索条件的内容:PagefindAll(Exampleexample,Pageablepageable);为此,我正在为搜索中包含的所有字段构建一个ExampleMatcher。像这样:privateExampleMatcherbuildMatcher(FormSearchParametersformSearchParameters){ExampleMatcherexampleMatcher=ExampleMatcher.matching().withIgnorePaths("f1","f2","f3","

cursor.sort() 中 undefined 与 null 的 MongoDB 语义

根据MongoDB中的信息manpageoncursor.sort(关于比较值的最后一段),就sort()函数而言,NULL值比任何其他值都小。问题是,缺少的属性是否视为NULL?根据我的测试不是这样:>db.sort.find().sort({id:1}){"_id":ObjectId("5269554df18e7d2f4bd1241d"),"a":"Anonym"}{"_id":ObjectId("52695684f18e7d2f4bd12421"),"a":"Bnonym","d":"iii"}{"_id":ObjectId("52695892f18e7d2f4bd12422")

mongodb - Angular 5 + Material 设计 : <mat-select> how to set the default value?

{{category.name}}我尝试了很多东西。文档、github上的一些错误报告仍然没有解决我的问题。我只想预设一个默认值...默认值存储在一个名为:resource.categoryName的变量中。这些选项来自mongodb的集合,这些存储在类别[]中。Thispictureshowstheclosedmat-select(nodefaultvalueshown,butitshould...)openedmat-selectHereismy.ts.Theimportantlineis"this.resource.categoryName=this.subdoc['name']

mongodb - 使用 $set 更新嵌入文档

我有一份这种形式的文件{"firstName":"John","lastName":"Doe","preferences":{"xxx":true,"yyy":false,"zzz":true}}我想更新preferences嵌入文档中的特定字段。如果我按以下方式使用$set操作数db.users.update({name:"John"},{$set:{preferences:{"xxx":false}}})preferences文件被完全替换,所以我明白了{"firstName":"John","lastName":"Doe","preferences":{"xxx":false}}

node.js - 返回 null 的 GraphQL 嵌套查询

尝试运行以下查询时出现此错误:“无法为不可为空的字段User.first_name返回空值。”。我不希望得到空结果。Query:{site(site_reference:123456789){site_namesite_managers{_idfirst_name}}}我希望看到的是:{"data":{"site":{"site_name":"TestSite","site_managers":[{"_id":"5bbcd55ff7bd643be4d490fa","first_name":"Claire"},{"_id":"5b9fa2e1f66fb32164f4d547","firs

codeigniter 2.2.2 dbforge产生默认值''null

dbforge->add_field(array('id'=>array('type'=>'INT','constraint'=>11,'unsigned'=>TRUE,'auto_increment'=>TRUE,),'parent_id'=>array('type'=>'INT','constraint'=>11,'unsigned'=>TRUE,'default'=>NULL,'null'=>TRUE,),));$this->dbforge->add_key('id',TRUE);$this->dbforge->create_table('clients_categories');}pu