1

I'm using RailwayJS, a Node.JS MVC framework based on ExpressJS, fully ExpressJS-compatible. I'm trying to figure out how to add/generate users, but couldn't find any documentation about it. Does anybody know how?

alexchenco
  • 53,565
  • 76
  • 241
  • 413
  • Using the eaxmple user schema or what? It uses a memory library as example, so it wouldnt make much sense. You could just create a user controller for testing purpose. What exactly are you trying to accomplish? :) – Marco Johannesen Mar 07 '12 at 13:46

1 Answers1

2

Do you mean on application startup?

In that case just define a user.js file under /config/initializers initi your model set the properties and save your model

as example this is how my /config/initializers/user.js looks like

var user;
user = new User;
user.username = "bob";
user.password = "secret";
user.email = "bob@example.com";
user.displayName = "Bob";
user.activated = true;
user.createdAt = new Date();
user.locale = "en";
user.save();

User.all(function(err, users) {
  var user, _i, _len, _results;
  _results = [];
  for (_i = 0, _len = users.length; _i < _len; _i++) {
    user = users[_i];
    _results.push(console.log(user));
  }
  return _results;
});

The last statement is just for logging the users that are loaded