Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed .js files? #96

Open
spacesuitdiver opened this issue Apr 20, 2017 · 1 comment
Open

Seed .js files? #96

spacesuitdiver opened this issue Apr 20, 2017 · 1 comment

Comments

@spacesuitdiver
Copy link

Can we seed .js files so we can make data up? That'd be super mega awesome.

@kelchm
Copy link

kelchm commented Dec 20, 2019

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants