How to use the bookshelf.ghost function in bookshelf

To help you get started, we’ve selected a few bookshelf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Laures / ghost-openshift-quickstart / core / server / models / base.js View on Github external
var ghostBookshelf,
    Bookshelf = require('bookshelf'),
    when      = require('when'),
    moment    = require('moment'),
    _         = require('underscore'),
    uuid      = require('node-uuid'),
    config    = require('../config'),
    Validator = require('validator').Validator,
    unidecode = require('unidecode'),
    sanitize  = require('validator').sanitize;

// Initializes a new Bookshelf instance, for reference elsewhere in Ghost.
ghostBookshelf = Bookshelf.ghost = Bookshelf.initialize(config().database);
ghostBookshelf.client = config().database.client;

ghostBookshelf.validator = new Validator();

// The Base Model which other Ghost objects will inherit from,
// including some convenience functions as static properties on the model.
ghostBookshelf.Model = ghostBookshelf.Model.extend({

    hasTimestamps: true,

    defaults: function () {
        return {
            uuid: uuid.v4()
        };
    },
github ohmlabs / ohm / server / ghost / core / server / models / base.js View on Github external
var Bookshelf = require('bookshelf'),
    when      = require('when'),
    moment    = require('moment'),
    _         = require('lodash'),
    uuid      = require('node-uuid'),
    config    = require('../config'),
    unidecode = require('unidecode'),
    sanitize  = require('validator').sanitize,
    schema    = require('../data/schema'),
    validation     = require('../data/validation'),

    ghostBookshelf;

// Initializes a new Bookshelf instance, for reference elsewhere in Ghost.
ghostBookshelf = Bookshelf.ghost = Bookshelf.initialize(config().database);
ghostBookshelf.client = config().database.client;


// The Base Model which other Ghost objects will inherit from,
// including some convenience functions as static properties on the model.
ghostBookshelf.Model = ghostBookshelf.Model.extend({

    hasTimestamps: true,

    // get permitted attributs from schema.js
    permittedAttributes: function () {
        return _.keys(schema.tables[this.tableName]);
    },

    defaults: function () {
        return {