ravendb / ravendb-nodejs-client

RavenDB node.js client
MIT License
63 stars 32 forks source link

Cannot query with where after moreLikeThis #409

Closed ayende closed 5 months ago

ayende commented 6 months ago

A query such as:

async function getDuplicates(question: Question): Promise<Question[]> {
  const session = ravenStore.openSession();
  const query = session
    .query<Question>({ indexName: "Questions/Search" })
    .whereEquals("isArchived", false)
    .whereNotEquals("id", question.id)
    .whereEquals("level", question.level)
    .moreLikeThis(q =>
      q.usingDocument(
        JSON.stringify({
          question: question.question,
        })
      )
    )
    .take(5);

  if(question.language)   query.whereEquals("level", question.level)

  const similarQuestions = await query.all();

  return similarQuestions;
}

This fails:

  if(question.language)   query.whereEquals("level", question.level)

Because the previous operation in not a where, which is what this expects