这是我的代码:
app.post('/ujfeladat', (req, res) => {
const {nev, tipus, szid} = req.body;
const hianyos = () => {
if(tipus === 'hianyos'){
return {rang: -1}
}
return
}
db('fl').insert({
nev: nev,
tipus: tipus,
szid: szid,
hianyos() //returns an error
}).returning('*')
.then(data => res.json(data))
.catch(err => console.log(err))
})
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能将rang
属性添加到对象中tipus === 'hianyos'
?
有没有办法为三元运算符返回任何内容我的意思是
const a = [ 0 ? { name : "example" } : null ]
Run Code Online (Sandbox Code Playgroud)
当我打印 a = [null] 时
或者:
const a = [ 0 && {name:"example"}]
Run Code Online (Sandbox Code Playgroud)
a 将是 [假]
我预计情况 1 的 a = []