1

I've dynamoose schema like below.

var dynamoose = require('dynamoose');
 
var City = dynamoose.model('City', { id: Number, name: String });

and City names data like 'City1', 'City2',...'City100'

I'm trying to get the cities whose city names are 'City2', 'City8' and i didn't find any solution

i tried like below

Model.scan({ name: { contains: 'City2' } }).exec();

How to add City8 also

Note: name column doesn't have any index

2

2 Answers 2

2

I see that you are using scan. I would use query as it's more performant and more.

The query can be something like:

CitiesModel.query("name").eq("City01").or().where("name").eq("City10").exec()

Regards!

Sign up to request clarification or add additional context in comments.

Comments

0

I would create a new index with name as hashkey and use .getBatch function. It takes an array of ids (I believe 50 ids is the size limit).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.