2
帆のJS(MongoDBの)中でさらに使用するための変数に結果のデータを格納したい、 はここに私のコードです私は次モデルに格納するデータベースから価格を取得したい
newOrder: function(req,res){
var data = req.body;
const orderNo = data.orderNo;
const user = data.user;
const business = data.business;
const inventory = data.inventory;
const price = Inventory.find({id: data.inventory}).exec(function(err,record){ return record.price});
const address = data.address;
const quantity = data.quantity;
const contactNumber = data.contactNumber;
Order.create({
orderNo: orderNo,
user: user,
business: business,
inventory: inventory,
price: price,
address: address,
quantity: quantity,
contactNumber: contactNumber
}).then(function(result){
res.ok(result);
});
},
Iそれが正しくないことを知っているが、私はそれを行う方法がわからない 内側のクエリは何も返されていない、 私は後で使用するために変数に結果のデータを保存したい。 ここ