How can I batch query by id when using JS/TS v3?

Is there a recommended way to query for multiple objects, based on their id, when using the JS/TS v3 client?

I see that I can query against a single id as follows:

const jeopardy = client.collections.get('JeopardyQuestion')
const response = await jeopardy.query.fetchObjectById('ed89d9e7-4c9d-4a6a-8d20-095cb0026f54')

However, I need to retrieve large batches; I can’t use a one-query-per-object approach.

I tried using fetchObjects and filters, using variations on something like this:

const result = await jeopardy.query.fetchObjects({
  filters: jeopardy.filter.byProperty('id').containsAny(["id1", "id2"])
})

But either the ‘id’ property cannot be accessed this way, or it must have a different name than either ‘id’, ‘uuid’, or ‘_additional.id’.

I saw this related question, which provided an approach for Python: Best way to query objects using id at once

But, it seems like the JS/TS v3 sdk cannot be used in this way. I suppose I can look at just POSTing the graphql queries myself, though naturally I prefer the uniformity of using the JS/TS v3 client, and it seems like it should have this functionality.

Is there a recommended way to query for multiple objects, based on their id, when using the JS/TS v3 client?

Hi, you can do

const myArticleCollection = client.collections.get('Article');
const creationTime = '2020-01-01T00:00:00+00:00'

result = await myArticleCollection.query.fetchObjects({
  filters: jeopardy.filter.byCreationTime().greaterOrEqual(creationTime),
  returnMetadata: ['creationTime']
})

for (let object of result.objects) {
  console.log(JSON.stringify(object.properties, null, 2));
}

See here: Filters | Weaviate - Vector Database

I think this must be the answer to a different question, since I’m asking about fetching multiple records by id.

I copied the wrong code example, but the link shows how to filter by id. Simply replace the .equal() in the example with . containsAny()

Thank you Dirk! Now it’s clear. I appreciate your help!