2017-12-26 32 views
0

APIをType ORMにmongooseから移行しています。私はデータベースから検索されるidのリストを含む配列(conversationIds)を持っており、それは私に利用可能なIDを返す必要があります。以下は私が試した質問です。 findメソッド(typeORM)で配列オブジェクトを渡す

const conversationMessagesWithDuplicates = await consversationRepository.createQueryBuilder("conversation").where("conversation.channel_message_ID = :channel_message_ID",{channel_message_ID : conversationIds}).getMany(); 

もこの1

const conversationMessagesWithDuplicates = await consversationRepository.find({channel_message_ID: conversationIds}); 

しかし、私は問題の下に取得しています:

(node:11548) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): QueryFailedError: Error: Incorrect syntax near ','. 

私も、エンティティマネージャを使用してみましたが

const conversationMessagesWithDuplicates = await entityManager.query(`SELECT channel_message_ID FROM Conversation where channel_message_ID IN (conversationIds)`); 

より下には成功workiであるMoongoseAPIです細かいNG:

Conversation.find({ channel_message_ID: { $in: conversationMessageIdArray } }).exec(function(err, conversationMessagesDuplicatesArray) {} 

答えて

0

これは

const conversationMessagesWithDuplicates = await consversationRepository.createQueryBuilder("conversation").where("conversation.channel_message_ID IN (:conversationIds)", { conversationIds: conversationIds }).getMany(); 
ソリューションです。
関連する問題