createdBy: function() {
    return this.belongsTo(models.user, 'created_by');
  },


  requirement: function() {
    return this.belongsTo(models.requirement);
  },

  status: function() {
    return this.belongsTo(models.status);
  },

}, {
  
  fields: ['id', 'requirement_id', 'amount', 'currency', 'payment_type', 'contact_no', 'contact_name', 'deposit_account', 'created_by', 'created_at', 'updated_at'],

  schema: [
    Fields.IntField('post_id', {required: true}),
    Fields.IntField('status_id', {required: true}),

    Fields.FloatField('amount'),
    Fields.StringField('currency'),
    
    Fields.IntField('created_by'),
    Fields.IntField('updated_by'),

    Fields.IntField('flag'),
  ]
});
Exemple #2
0
var models = require('../models');

module.exports = bookshelf.Model.extend({ 
  tableName: 'followup',
  
  initialize: function(attributes, options) {
    this.on('saving', this.beforeSave);
  },

  beforeSave: function(model, attrs, options){
    //do some actions before saving the model
  },

  createdBy: function() {
    return this.belongsTo(models.user, 'created_by');
  },

  hasTimestamps: true
}, {
  schema: [
    Fields.IntField('entity_type_id', {required: true}),
    Fields.IntField('entity_id', {required: true}),
    
    Fields.StringField('body'),
    
    Fields.IntField('created_by'),
    Fields.IntField('updated_by'),

    Fields.IntField('flag'),
  ]
});
Exemple #3
0
    //do some actions before saving the model
  },

  category: function() {
    return this.belongsTo(models.category);
  },

  queue: function() {
    return this.belongsTo(models.queue);
  },

  status: function() {
    return this.belongsTo(models.status);
  },

}, {
  schema: [
    Fields.IntField('category_id', {required: true}),
    Fields.IntField('queue_id', {required: true}),
    Fields.IntField('status_id', {required: true}),

    Fields.StringField('title'),
    Fields.StringField('body'),
    
    Fields.IntField('created_by'),
    Fields.IntField('updated_by'),

    Fields.IntField('flag'),
  ],
  fields: ['id', 'category_id', 'queue_id', 'status_id', 'title', 'body', 'created_by', 'updated_by', 'flag'],
});
Exemple #4
0
var Fields = require('bookshelf-schema/lib/fields');
var bookshelf = require('../bookshelf');
var models = require('../models');

module.exports = bookshelf.Model.extend({ 
  tableName: 'item',
  
  initialize: function(attributes, options) {
    this.on('saving', this.beforeSave);
  },

  beforeSave: function(model, attrs, options){
    //do some actions before saving the model
  },

  post: function() {
    return this.belongsTo(models.post);
  },

}, {
  schema: [
    Fields.IntField('entity_type_id', {required: true}),
    Fields.IntField('entity_id', {required: true}),

    Fields.StringField('item_name'),
    Fields.FloatField('quantity'),
    Fields.FloatField('price'),
    Fields.FloatField('line_total')
  ]
});