我正在从mongoose将API迁移到TypeORM。我有一个数组(conversationIds)包含要从数据库中搜索的id列表,它应该返回我可用的id。以下是我试过的查询。
name:
还有这个
public static function getMail($sessionValue){
$dbObject = new database();
$condition = "session ='".$sessionValue."'";
$amountObject = $dbObject->getData("tbl_purchasedetail",$condition);
while ($row = $amountObject->fetch_assoc()) {
echo $row['name']."<br>";
echo $row['NRIC']."<br>";
}
}
但是我遇到了问题:
const conversationMessagesWithDuplicates = await consversationRepository.createQueryBuilder("conversation").where("conversation.channel_message_ID = :channel_message_ID",{channel_message_ID : conversationIds}).getMany();
我也试过使用实体Manger但没有成功
const conversationMessagesWithDuplicates = await consversationRepository.find({channel_message_ID: conversationIds});
以下是工作正常的MoongoseAPI:
(node:11548) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): QueryFailedError: Error: Incorrect syntax near ','.
答案 0 :(得分:0)
这是解决方案
const conversationMessagesWithDuplicates = await consversationRepository.createQueryBuilder("conversation").where("conversation.channel_message_ID IN (:conversationIds)", { conversationIds: conversationIds }).getMany();