Reputation: 1
I have a DynamoDB table with the following schema:
import { Schema } from "dynamoose/dist/Schema";
export const ObjectSchema = new Schema ({
id: {
type: String,
hashKey: true,
},
values: {
type: Array,
schema: [String],
}
});
I want to select all items where the values
array contains a specific string.
I tried the following approaches:
.scan().where('values').contains(value)
and
.scan('values').contains(value)
However, both attempts result in the error:
TypeError: node.forEach is not a function
Here’s the method that I'm using:
async findByValue(
value: string,
): Promise<ExampleObject[]> {
return await this.objectModel
.scan('values')
.contains(value)
.exec();
Is there a way to query all items with the specific value
in the values
array, without retrieving all the items in the client and filtering them manually?
Upvotes: 0
Views: 48