serverless-dynamodb-local
serverless-dynamodb-local copied to clipboard
Seed .js files?
Can we seed .js files so we can make data up? That'd be super mega awesome.
Just wanted to leave a note here to say that this is possible.
seed/test.js
const faker = require('faker');
const seedUsers = (userCount = 10) => {
const dataRows = [];
for (let userIndex = 0; userIndex < userCount; userIndex += 1) {
const user = faker.helpers.userCard();
dataRows.push({
Id: faker.random.uuid(),
Label: faker.random.word(),
name: user.name,
email: user.email,
});
}
return dataRows;
};
module.exports = seedUsers();
Simply set test.js
as one of the sources in your serverless configuration:
custom:
dynamodb:
seed:
test:
sources:
- table: TestTable
sources: [./seed/test.js]