我正在尝试使用以下Go代码行从MongoDB中删除记录:
mg.collection.Remove(bson.M{"id": 1})
此命令返回一个未找到的错误,但下面的代码在终端和Robomongo中没有问题:
db.getCollection('main').remove({"id":1})
我在Go中做错了什么?
由于
答案 0 :(得分:0)
查看更多代码会很有帮助,但我想我知道你要做的是什么。您可以在var Validator = require('jsonschema').Validator;
var v = new Validator();
var instance = {
"original_image": {
"temp_id": "this is my id",
"scale": {
"new_width": null,
"new_height": 329
}
}
};
var schema = {
title: "Example Schema",
type: "object",
properties: {
original_image:{
type: "object",
properties: {
temp_id: {type: "string"},
url: {type: "string"},
scale:{
type: "object",
properties:{
new_width: {type: "number"},
new_height: {type: "number"}
},
required:["new_width","new_height"]
}
},
required:["url","temp_id","scale"]
}
},
required:["image"]
};
console.log(v.validate(instance, schema));
上致电Remove
。
所以(为简洁起见,错误处理):
collection
是会话变量:
session