gpt4 book ai didi

sequelize.js - sequelize 创建函数只保存几个字段

转载 作者:行者123 更新时间:2023-12-03 22:41:36 25 4
gpt4 key购买 nike

我有以下代码:

socket.on("add_upload", function(upload){
var data = upload.building_data.data;
var obj = {
condo_owner : getContent(data,"Condo/Owner"),
address : getContent(data,"Address"),
state_province : getContent(data,"State/Province"),
country : getContent(data,"Country"),
email : getContent(data,"Email"),
suite : getContent(data,"Resident Suites"),
mgt_company : getContent(data, "Mgt. Company"),
telephone : getContent(data,"Telephone"),
billing_account_no : getContent(data,"Billing Account #"),
billing_count : getContent(data,"Billing Count"),
billing_type : getContent(data,"Billing Type"),
calculation_type : getContent(data,"Calculation Type"),
meter_type : getContent(data,"Meter Type"),
remittance_type : getContent(data, "Remittance Type"),
city : getContent(data, "City"),
postal_code : getContent(data, "Zip/Postal Code")
};
console.log(obj);
Uploads.create(upload.upload).then(function(){
Buildings.create(obj).then(function(){
socket.emit("add_upload_successfull");
});
});
});

在 console.log 上它正确显示所有字段,但是当我使用 Create 时它只显示两个正在保存的字段,因为它应该显示保存在数据库中的所有字段。我仔细检查了字段名称,它们是正确的。

最佳答案

Uploads.create(upload.upload).then(function(){
Buildings.create(obj).then(function(){
socket.emit("add_upload_successfull");
});
});

这应该使用 obj 还是 upload.building_data ?您经历了将数据内容解析为 obj 的所有麻烦,然后使用任何 upload.upload 调用 Uploads.create。我们不知道 upload.upload 是什么,我们只知道你解析的数据来自 upload.building_data
我的第一个想法是简单地将上面的内容更改为使用正确的对象:
Uploads.create(obj).then(function(){
Buildings.create(obj).then(function(){
socket.emit("add_upload_successfull");
});
});

关于sequelize.js - sequelize 创建函数只保存几个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42007212/

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