From df9fe90d35e3fee13145c69362d29ba22787ee76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 9 Oct 2014 17:46:36 +0200 Subject: [PATCH] Auto-load and register built-in `Checkpoint` model --- common/models/change.js | 2 +- lib/builtin-models.js | 1 + test/checkpoint.test.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/models/change.js b/common/models/change.js index ed347eeb..bedfc1cc 100644 --- a/common/models/change.js +++ b/common/models/change.js @@ -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); diff --git a/lib/builtin-models.js b/lib/builtin-models.js index f2df14c9..52bb2719 100644 --- a/lib/builtin-models.js +++ b/lib/builtin-models.js @@ -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 diff --git a/test/checkpoint.test.js b/test/checkpoint.test.js index c999729f..0b7aa3f2 100644 --- a/test/checkpoint.test.js +++ b/test/checkpoint.test.js @@ -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() {