noppoMan / npdynamodb

A Node.js Simple Query Builder and ORM for AWS DynamoDB
112 stars 19 forks source link

Support both of static and prototype custom properties extend for ORM. #4

Closed noppoMan closed 9 years ago

noppoMan commented 9 years ago

Support both of static and prototype custom properties extend for ORM like bellow.

npdynamodb.define('model', {
  dynamodb: require('./dynamodb_2012_08_10'),

  hashKey: 'hash_key',

  rangeKey: 'range_key',

  customProtoConstant: 1,

  customProtoMethod: function(){
    return this.get('hash_key') === 1;
  }
},

{
  customStaticConstant: 1,

  customStaticMethod: function(){
    return this.where('hash_key', 1).fetch();
  }
});

// Usecase

Model.find(1).fetch().then(funciton(model){
  model.customProtoMethod();
});

Model.customStaticMethod();
noppoMan commented 9 years ago

Done at 5d51551.