Skip to content

Instantly share code, notes, and snippets.

@leemason
Created May 6, 2016 19:21
Show Gist options
  • Save leemason/b7b96918dda050a6cdf140b8f85d55e7 to your computer and use it in GitHub Desktop.
Save leemason/b7b96918dda050a6cdf140b8f85d55e7 to your computer and use it in GitHub Desktop.
Hybrid ORM
var Mapper = require('./Mapper'),
Model = require('./Model');
var User = Model.extend({
attributes: {
name: String,
email: String
}
});
var UserRepository = Mapper.extend({
model: User,
map: function(user){//optional method to map model attributes to persistance columns, just return a key, value object
}
});
var user = UserRepository.create();//returns an instance of User
user.name = 'Lee Mason';
UserRepository.save(user);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment