84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
比如我想增加一个is_delete 字段,想指定类型为int_32,并且默认值为0.没有找到好办法我现在做的是添加这个字段,值为1,然后类型就自动为int_32,然后在批量update为0.如果直接为0.他显示的是bool false
is_delete
int_32
0
1
updat
bool false
有没有更简单方法呢。
欢迎选择我的课程,让我们一起见证您的进步~~
It doesn’t seem to work, I haven’t seen a way to set it at the database level. For NOSQL like MongoDB, you have to use ORM or business code to deal with this problem.
As for what you said, it shouldn’t show bool false after update, right?
> db.test.save({'a':1,'b':1}) WriteResult({ "nInserted" : 1 }) > db.test.find() { "_id" : ObjectId("5625f1d9d782d26c6536ee8c"), "a" : 1, "b" : 1 } > db.test.update({'a':1},{'$set':{'b':0}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.test.find({'a':1}) { "_id" : ObjectId("5625f1d9d782d26c6536ee8c"), "a" : 1, "b" : 0 } >
Isn’t this still 0?
It doesn’t seem to work, I haven’t seen a way to set it at the database level. For NOSQL like MongoDB, you have to use ORM or business code to deal with this problem.
As for what you said, it shouldn’t show bool false after update, right?
Isn’t this still 0?