Javascript 如何在typeorm中使用按userId或null查找?

Javascript 如何在typeorm中使用按userId或null查找?,javascript,sql,node.js,typeorm,Javascript,Sql,Node.js,Typeorm,我在sql中使用typeorm 我想根据userId或我没有userId(null)的地方获取所有产品 使用find函数如何实现这一点 此代码未按预期返回结果: const userId=22; Product.find({ 其中:{ 用户:IsNull()| 124; userId } }); 您可以将数组传递给where,它实际上是一个或子句 const userId=22; Product.find({ 其中:[ {user:IsNull()}, {user:userId} ] }); 您

我在sql中使用typeorm

我想根据
userId
或我没有
userId
(null)的地方获取所有
产品

使用
find
函数如何实现这一点

此代码未按预期返回结果:

const userId=22;
Product.find({
其中:{
用户:IsNull()| 124; userId
}
});

您可以将数组传递给
where
,它实际上是一个
子句

const userId=22;
Product.find({
其中:[
{user:IsNull()},
{user:userId}
]
});

您可以将数组传递给
where
,它实际上是一个
子句

const userId=22;
Product.find({
其中:[
{user:IsNull()},
{user:userId}
]
});