如何匹配表并在nodejs中使用where子句查找所有内容

时间:2019-01-20 10:27:16

标签: node.js sequelize.js

我在交易表中使用此cardnum拥有cardnum字段,如何获取cid并匹配wallet cid字段以更新钱包字段金额

此处cid表示用户表ID(默认值),该表在所有表中均变为cid

 INSERT INTO `transaction` (`id`,`name`,`cardnum`,`amount`,`amountsplit`,`netamtdebt`,`addedon`,`payumoneyid`,`txnid`,`txnstatus`,`txnmsg`,`email`,`mobile`,`bankrefnum`,`custcardnum`,`pgtype`,`productinfo`,`status`) VALUES (DEFAULT,'coin','27','5644','865','120','2008-12-02 04:35:51','8532648','615651','success','successfully posted','dineshgrt@gmail.com','98798615','516516161','65461531','individual','updated succesfully!!!!','true');

body {“ cid”:“ 27”,“ amount”:“ 5644”,“ status”:“ true”} 正在执行(默认):插入walletid)值(默认); 未捕获的错误{文件名:'\ cl-api-master \ services \ AuthService.js',   行:147,   行:12   消息:“分配给常量”。   类型:“ TypeError”,   堆栈:'TypeError:分配给常量变量。\ n在Object.update(E:\ cl-api-master \ services \ AuthService.js:147:12)\ n在',   参数:undefined} POST / m1 / payu / transaction--ms--

 [err, remainingwallet] = await to(wallet.findAll(
    {
    limit :1,
    where : {   
        cid : wallet_inf.cid=User.id,
    },        
    transaction: [
        ['id','DESC']
    ]        
    }
));
if(wallet_inf.status = true){
 [err, wallet] = await to(wallet.create(wallet.deposit = wallet_inf));
 if(err) return TE(JSON.stringify(err));
 wallet.available = remainingwallet[0].available + wallet_inf.amount;
 updated = true;
 [err, wallet] = await to(wallet.save());
 if(err) return TE(JSON.stringify(err));
}
else{
    TE('Please check your balance')
}
 return wallet;

我想使用交易金额更新钱包字段金额

0 个答案:

没有答案