Giter VIP home page Giter VIP logo

seeder's People

Contributors

axelvaindal avatar cleverbeagle avatar rglover avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

seeder's Issues

How to attach multiple collections to the same user

Is it already possible to attach multiple collections to the same user, something like :

  (same as last example of documentation)
   data(userId) {
        return [documentsSeed(userId), tasksSeed(userId)];
      },

or it is a new feature request ?

Add to documentation staging mode

If you want to seed in staging mode, you add

environments: ['development', 'staging'] 

but if you deploy using mup (or galaxy), you need to explicitly add in you mup.js config file (with ROOT_URL and such)

NODE_ENV: 'staging',

Otherwise the condition won't match (default is production if not development)

environmentAllowed(environments) {
    if (environments) return environments.indexOf(process.env.NODE_ENV) > -1;
    return false;
}

Maybe a little warning in documentation might help.

dependant collection seeding not working for collection other than `Meteor.users`

When trying to seed dependant collections, it seems that the data function field is never called, unless the collection is Meteor.users.

Let's take the code from pup and add a Videos collection. The Videos collection is seeded, but not the Documents

import Videos from '../../api/Videos/Videos'; // Videos collection

const documentsSeed = ...

seeder(Videos, {
  environments: ['development', 'staging'],
  wipe: true,
  noLimit: true,
  modelCount: 3,
  model(index) {
    console.log(`creating videos ${index + 1}`);
    return {
      title: `Title of video #${index + 1}`,
      data(videoId) {
        console.log('This is never called');
        return documentSeed(videoId);
      },
    };
  },
});

Do not send emails for fake signups?

Every time my meteor server restarts (often), a batch of 100 test users are created. Ever time a user is created, I send out two emails: one welcome email and a verification email. Sending these emails is taxing on local development, not necessary for development purposes, and costs $ (I use SES).

Is there a way we can specify to not fire emails on these fake sign ups?

Fake facebook sign ups?

My application supports signing up via Facebook in addition to normal email and password.

Can this package support faking Facebook-based users?

Seeding users doesn't work if there is no field username

Here is solution to index.js

  createUser(collection, user, iteration) {
    const userToCreate = user;
/*    // Error: if username is null finds first with null and isExistingUser has true
    const isExistingUser = collection.findOne({
      $or: [
        { 'emails.address': userToCreate.email },
        { username: userToCreate.username }, 
      ]
    });
*/
    let condition = [{ 'emails.address': userToCreate.email }];
    if (userToCreate.username) {
      condition.push({ username: userToCreate.username });
    }
    const isExistingUser = collection.findOne({$or: condition });

    if (!isExistingUser) {
      const roles = userToCreate.roles;
      if (roles) delete userToCreate.roles;
      const userId = Accounts.createUser(userToCreate);
      if (roles && Roles !== 'undefined') Roles.addUsersToRoles(userId, roles);
      if (userToCreate.data) this.seedDependent(userId, userToCreate.data, iteration);
    }
  }

Add verbose mode

Hi, great work for this package.

Is it possible to add verbose mode so it would print the progress of the seeding in the server console ?
This is particularly useful for displaying information about which data is finally present in the database and displaying smooth error (or ignoring them on production for instance).

I think a verbose boolean should be added to the seeder object in order to enable/disable verbose mode. If enabled, it would print :

  • The current object being populated and status (i.e "Seeding object nยฐX to CollectionName").
  • A brief overview of success and failure (i.e "Seeding complete : X inserted, Y failed.")

This could be improved for much more information about populated data, but I suppose this is enough for most usage and a good start ๐Ÿ™‚

Allow custom logic in `data` method (no return value)

I want to add a bunch of dependent data after users have been inserted. Right now the extra data method requires you to return a function that specifies a single collection name. But this doesn't work for complex systems that have dependent data that needs to go into multiple collections, simultaneously (i.e. if you follow someone, an insert needs to happen on both the Followers and Followees collections).

It would be great if data did not require a return value, which would allow the developer to write any old javascript function containing their custom logic. I.e.

      data(userId) {
        createUserFollowships(userId);
      },

Notice the omission of return. The above code works functionally, however the Meteor console gets spammed with errors:

 TypeError: Cannot read property 'collection' of undefined
W20170718-15:17:47.814(-4)? (STDERR)     at Seeder.seedDependent (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:109:50)
W20170718-15:17:47.814(-4)? (STDERR)     at Seeder.createUser (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:96:37)
W20170718-15:17:47.814(-4)? (STDERR)     at Seeder.sow (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:64:20)
W20170718-15:17:47.814(-4)? (STDERR)     at Seeder.seed (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:45:23)
W20170718-15:17:47.814(-4)? (STDERR)     at new Seeder (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:26:12)
W20170718-15:17:47.815(-4)? (STDERR)     at exports.default (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/@cleverbeagle/seeder/index.js:117:10)
W20170718-15:17:47.815(-4)? (STDERR)     at users.js (imports/startup/server/fixtures/users.js:18:7)
W20170718-15:17:47.815(-4)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:333:9)
W20170718-15:17:47.815(-4)? (STDERR)     at require (packages/modules-runtime.js:228:16)
W20170718-15:17:47.815(-4)? (STDERR)     at index.js (imports/startup/server/fixtures/index.js:3:1)

Improve test suite

A lot has been learned about tests since this package was released. Would be good to improve tests and realign with new 2.0.0 features.

Refactor code for clarity

v1 of this package has worked well, but the internals are a bit confusing coming back to it. Need to do a refactor of the code to simplify it and make extension/maintenance a little easier.

Add .generate() method

Right now the seeder works well enough for seeding on startup, but it'd be nice if you could call it and get back data without hitting the DB. E.g., to generate seed data for tests.

Fix SimpleSchema sanitizing dependentData before it's used

Forgot about this problem from v1. Due to how the SimpleSchema package works (commonly used for defining schemas on MongoDB collections in Meteor), it scrubs any data that doesn't match the schema. dependentData gets caught up in this. Need to cache dependentData in a variable and remove it before passing a date item to a collection in case it's using SimpleSchema.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.