Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function() {
// inject model into promise chain as return value
return bookshelf.Model.extend({
tableName: 'genres'
});
})
.catch(function(e) {
(function () {
"use strict";
// We should just be able to require bookshelf and have it reference
// the `Knex` instance bootstraped at the app initialization.
var Bookshelf = require('bookshelf'),
Showdown = require('showdown'),
converter = new Showdown.converter(),
Post,
Posts,
User,
Setting,
Settings;
Post = Bookshelf.Model.extend({
tableName: 'posts',
hasTimestamps: true,
initialize: function () {
this.on('creating', this.creating, this);
this.on('saving', this.saving, this);
},
saving: function () {
if (!this.get('title')) {
throw new Error('Post title cannot be blank');
}
this.set('content_html', converter.makeHtml(this.get('content')));
.then(function() {
var Genres;
Genres = bookshelf.Model.extend({
tableName: 'genres'
});
return Genres.count()
.then(function(count) {
if (count > 0) {
return Promise.resolve();
}
log.info('populating Genres from tmdb');
tmdb = tmdb(config.apiKey);
console.log(_.isFunction(tmdb.genreList));
console.log(_.keys(tmdb));
tmdb.genreList(function(genres) {
console.log(genres);
throw 'die';
});
/*
return this.set('slug', this.get('title').replace(/\:/g, '').replace(/\s/g, '-').toLowerCase());
},
user: function () {
return this.belongsTo(User, 'created_by');
}
});
Posts = Bookshelf.Collection.extend({
model: Post
});
User = Bookshelf.Model.extend({
tableName: 'users',
hasTimestamps: true,
posts: function () {
return this.hasMany(Posts, 'created_by');
}
});
Setting = Bookshelf.Model.extend({
tableName: 'settings',
hasTimestamps: true
});
Settings = Bookshelf.Collection.extend({
model: Setting
});