2

I am trying to create a model using Waterline ORM & sails.js for a postgresql db. I have a model defined like this.

var Waterline = require('waterline');
var Item = Waterline.Collection.extend({
    identity: 'item',
    connection: 'postgresqlServer',

    attributes: {
    title: {
       type: 'text'
    },
    brand: {
       type: 'text',
      defaultsTo: 'Other'
    },
    description: {
      type: 'text'
    },
    category: {
     type: 'text'
   }
  }
});

The table corresponding to the model gets created in the DB, but other than the default generated id, createdAt & updatedAt columns, no other column is reflected.

When my config is pointing to the localdiskdb, this seems to work fine. It's happening when I change the endpoint to a postgres instance running on AWS.

Any ideas ?

Update: I was able to resolve this. Instead of extending waterline, I used the conventional sails model format.

module.exports = {
    identity: 'item',
    connection: 'postgresqlServer',

    attributes: {
    title: {
       type: 'text'
    },
    brand: {
       type: 'text',
      defaultsTo: 'Other'
    },
    description: {
      type: 'text'
    },
    category: {
     type: 'text'
   }
  }
}
Suh
  • 23
  • 3
  • Are you using any libraries for running migrations? – Yedhu Krishnan Dec 29 '14 at 04:40
  • I tried using the option migrate with safe,alter & drop before sails lifting. 'drop' recreates the table but without any of the columns mentioned in the model attributes – Suh Dec 29 '14 at 15:28

0 Answers0