gpt4 book ai didi

mongodb - Mongoose 选择、填充和保存在 Mac 和 Windows 上的行为不同

转载 作者:可可西里 更新时间:2023-11-01 09:34:14 26 4
gpt4 key购买 nike

这是我做的

static populateReferralLinks(){
return Promise.coroutine(function*(){
let companies = yield Company.find({},'billing referral current_referral_program')
.populate('billing.user','emails name');

for(let i = 0 ; i < length ; i++){
companies[i].referral.is_created = true;
companies[i].referral.referral_email = companies[i].billing.user.emails[0].email;
companies[i] = yield companies[i].save();
}
return companies;
}).apply(this)
.catch((err) => {
throw err;
});
}

我有一个功能,我只选择 3 个字段继续进行,即计费、current_referral_program 和 referral。并使用存储在 billing.user 中的引用填充用户。现在当我在线调用这个函数时

公司[i].save();

在windows的终端中显示如下命令

Mongoose: companies.update(
{ _id: ObjectId("58d12e1a588a96311075c45c") },
{ '$set':
{ billing:
{ configured: false,
user: ObjectId("58d12e16588a96311075c45a") },
referral:
{ is_created: true,
referral_email: 'jadon.devesh98@gmail.com',
},
updatedAt: new Date("Wed, 22 Mar 2017 12:02:55 GMT")
}
}
)

但是在 Mac 的终端中它显示这个命令

Mongoose: companies.update({ _id: ObjectId("58d12e1a588a96311075c45c") }) { '$set': { billing: { configured: false, user: ObjectId("58d12e16588a96311075c45a") }, current_limit: {}, current_usage: {},referral: { is_created: true, referral_email: 'jadon.devesh98@gmail.com'}}, '$unset': { updatedAt: 1 } }

现在,我还没有提到 current_limitcurrent_usage 为空。它在 Windows 上执行良好,但在 Mac 上它设置 current_limitcurrent_usage 为空,因此在 Mac 上用空对象更新我的文档,但在 Windows 上没有。

它在两个操作系统上的行为应该相同,但事实并非如此。

最佳答案

显然这个问题在 Mongoose 4.5.8 中存在,并在最新版本即 4.9.1 中得到解决 Check it here

关于mongodb - Mongoose 选择、填充和保存在 Mac 和 Windows 上的行为不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42959922/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com