This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chunksize = 50; | |
return (function next(items) { | |
if (!items.length) { return; } | |
return knex('sites') | |
.insert(items.slice(0, chunksize)) | |
.then(function () { | |
return next(items.slice(chunksize)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bookshelf code, to compliment the knex code above | |
exports.PG = Bookshelf.PG = Bookshelf.initialize | |
client: 'pg' | |
connection: config.get('/postgres') | |
# property photo model | |
exports.PropertyPhoto = PropertyPhoto = Bookshelf.PG.Model.extend | |
tableName: 'property_photos' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Parent = Bookshelf.Model.extend({ | |
tableName: 'parent', | |
child: function() { | |
return this.hasOne(Child); | |
} | |
}); | |
var Child = Bookshelf.Model.extend({ | |
tableName: 'child', | |
//this has an attribute parent_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace 'TimeLog.View', (exports) -> | |
class exports.Log extends Backbone.View | |
tagName: 'li' | |
events: | |
'click .date': 'lala' | |
template = _.template(""" |