Auto-load and register built-in `Checkpoint` model

This commit is contained in:
Miroslav Bajtoš 2014-10-09 17:46:36 +02:00
parent 242b44ed2b
commit df9fe90d35
3 changed files with 3 additions and 2 deletions

View File

@ -441,7 +441,7 @@ Change.rectifyAll = function(cb) {
Change.getCheckpointModel = function() {
var checkpointModel = this.Checkpoint;
if(checkpointModel) return checkpointModel;
this.checkpoint = checkpointModel = require('./checkpoint').extend('checkpoint');
this.checkpoint = checkpointModel = loopback.Checkpoint.extend('checkpoint');
assert(this.dataSource, 'Cannot getCheckpointModel(): ' + this.modelName
+ ' is not attached to a dataSource');
checkpointModel.attachTo(this.dataSource);

View File

@ -8,6 +8,7 @@ module.exports = function(loopback) {
loopback.ACL = require('../common/models/acl').ACL;
loopback.Scope = require('../common/models/acl').Scope;
loopback.Change = require('../common/models/change');
loopback.Checkpoint = require('../common/models/checkpoint');
/*!
* Automatically attach these models to dataSources

View File

@ -2,7 +2,7 @@ var async = require('async');
var loopback = require('../');
// create a unique Checkpoint model
var Checkpoint = require('../common/models/checkpoint').extend('TestCheckpoint');
var Checkpoint = loopback.Checkpoint.extend('TestCheckpoint');
Checkpoint.attachTo(loopback.memory());
describe('Checkpoint', function() {