var Model = require('chaos-orm').Model;
var ImageTag = require('./image-tag');
var Gallery = require('./gallery');

class Image extends Model {
  static _define(schema) {
    schema.column('id', { type: 'serial' });
    schema.column('gallery_id', { type: 'integer' });
    schema.column('name', { type: 'string', null: true });
    schema.column('title', { type: 'string', length: 50, null: true });

    schema.belongsTo('gallery', 'Gallery', { keys: { gallery_id: 'id' } });
    schema.hasMany('images_tags', 'ImageTag', { keys: { id: 'image_id' } });
    schema.hasManyThrough('tags', 'images_tags', 'tag');
  }
}

Image.register();

module.exports = Image;
var Model = require('chaos-orm').Model;
var ImageTag = require('./image-tag');
var Gallery = require('./gallery');

class Image extends Model {
  static _define(schema) {
    schema.column('id', { type: 'serial' });
    schema.column('gallery_id', { type: 'integer' });
    schema.column('name', { type: 'string', null: true });
    schema.column('title', { type: 'string', length: 50, null: true });

    schema.belongsTo('gallery', 'Gallery', { keys: { gallery_id: 'id' }, null: true });
    schema.hasMany('images_tags', 'ImageTag', { keys: { id: 'image_id' } });
    schema.hasManyThrough('tags', 'images_tags', 'tag');
  }
}

Image.register();

module.exports = Image;
Apply core changes which define foreign keys to be not null by default.
Apply core changes which define foreign keys to be not null by default.
