- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在 mongoose 中有一个 upsert 查询,它在 3.8 中运行,但是在我升级到 4 之后,我得到了
Unable to invalidate a subdocument that has not been added to an array
这是我的模型:
var ActivitySchema = new Schema({
owner:{
type: Schema.Types.ObjectId,
ref: 'User'
},
sequence:{
type:Number,
default: 0
},
items:[
{
posted:{
type:Date,
default:Date.now
},
verb:{
type: String,
enum: [ 'leave','join','support','share','comment', 'upload', 'rate','message','update', 'signup']
},
text:{
type: String,
},
reference: {
objectType:{
type: String,
enum: [ 'document','element','process', 'project', 'user']
},
refObj:{}
}
}]
});
更新插入:
Activity.update({
$and:[
{'owner':ownerId},
{'sequence':bucket}
]},
{
$push:{items:newItem }
},
{
upsert:true
}).execAsync();
数据是这样的:
//newItem
{ verb: 'join',
text: 'Has joined to a team',
reference:
{
refObj: { teamId: '56269fd1e923cc7a7b46dcf8', name: 'test1' },
objectType: 'user'
}
}
ownerId 是一个 mongoId,例如 56251c01507dc35423694118bucket是一个整数0
是否有任何我需要注意的重大变化?我一直在寻找但尚未找到相关的任何其他解决方法、解决方案?
最佳答案
我遇到过同样的问题,如果情况相同,请确保所有字段类型都与 mongoose.model('yourModel')
匹配。希望有所帮助。
关于javascript - 更新 : Unable to invalidate a subdocument that has not been added to an array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33271196/
我的数据库架构如下所示: { "_id" : 137, "name" : "Tamika Schildgen", "scores" : [ { "score" : 4.4339
我正在寻找有关关闭属性选择的正确语法的帮助,该属性是一组子文档。我希望有一些类似的东西: var UserSchema = new Schema( { fb_id
我正在执行一个循环和更新,类似于this . 我有一个包含如下字段的现有文档: "field1" : { "field2" : [] } 使用空数组。 使用 Java,如何将文档放入空数组中?
我有以下型号: 产品: var ProductSchema = new Schema({ name: String, comments: [{ type: Schema.Types.ObjectId,
我一直在尝试通过 _id 在找到的文档中获取子文档。 示例架构 var User = mongoose.Schema({ name: String, pho
我有以下 mongo 集合: { "_id" : ObjectId("000000000001"), "username" : "user1", "password" : "p
我是 Express/Mongoose 和后端开发的新手。我正在尝试在我的架构中使用 Mongoose 子文档并将数据从表单发布到 MLab 数据库。 当我只使用父架构时,我成功地发布到数据库,但是当
具有以下更新查询: var template = {name:'my_name', ...}; ApplicationModel.update({ _id: idApplication
我有一个名为 Routine 的类,它具有属性名称和练习。 RoutineExercises 类型的 ArrayList 中的练习。 当我将我的例程写入我的 Firestore 数据库时,它会像它应该
在 mongoose 上,有一个很好的选项可以默认使用 select: false 选项从查询中删除一些字段。 例如: var FileSchema = new Schema({ filename
我在 dotnetcore 2.1 中使用 MongoDB.Driver nuget 包。我正在尝试返回集合中的文档列表,其中子文档字段等于我拥有的列表中包含的任何项目。理想情况下,我需要在 C# 语
我在 mongoose 中有一个 upsert 查询,它在 3.8 中运行,但是在我升级到 4 之后,我得到了 Unable to invalidate a subdocument that has
我已经开始学习Mongo了。给定以下集合,例如所谓的帖子,我将如何将新评论插入到现有文档中?我在 mongo 网站上看到的示例是针对“简单”集合的。感谢您的帮助。 { "_id" : ObjectId
例如我们有收藏 {field: {subfield: 'name'}} {field: {subfield: 'phone'}} 我可以找到没有点符号的文档吗?像这样 db.test.find({fi
我正在尝试在聚合上使用 $filter 。我需要过滤一个名为“extras”的数组,该数组至少与他的一个“季节”与给定的“日期”相交。 这里是一个例子: var from = new Date(201
我有一个使用expressjs和mongoosejs编写的Web api。 应用程序中的主架构包含一个子文档permissions,其中包含数组字段。这些数组包含可以对该文档执行操作的用户 ID。 我
通过指定 fields 参数,可以轻松管理 db.find() 结果集中某些字段的存在(我使用 Meteor 并在服务器端测试所有查询, 在发布功能中)。说 Meteor.collection.fin
我是一名优秀的程序员,十分优秀!