geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Save Method issue #265

Open MayankJari opened 7 years ago

MayankJari commented 7 years ago

After Creating Model and using create() method to store data , but as soon as i execute save() method it is not going inside save method , I don't know what is an issue.

var model = require('model');
var Listing = function(){

    this.defineProperties({
        name: { type: 'string', required: true },
        age : {type:'number',required : true}
    });

    this.setAdapter('postgres', {
        host: 'xxx.xxx.xx.xx',
        username: 'postgres',
        password: 'xxxxxxx',
        database: 'xxxxxxx'
    });
  //Connection Status  : Success
};
Listing = model.register('Listing',Listing);
var list = Listing.create({
    name : 'xyz',
    age : 20
});
 list.save(function (err, data) {
        if (err) {
            throw err;
        }
        console.log('New item saved!');
    });