models: move Change LDL def into a json file

This commit is contained in:
Miroslav Bajtoš 2014-10-13 11:58:14 +02:00
parent 6cbc231fba
commit 0906a6f5b3
4 changed files with 575 additions and 563 deletions

File diff suppressed because it is too large Load Diff

25
common/models/change.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "Change",
"trackChanges": false,
"properties": {
"id": {
"type": "string",
"id": true
},
"rev": {
"type": "string"
},
"prev": {
"type": "string"
},
"checkpoint": {
"type": "number"
},
"modelName": {
"type": "string"
},
"modelId": {
"type": "string"
}
}
}

View File

@ -33,7 +33,9 @@ module.exports = function(loopback) {
require('../common/models/user.json'),
require('../common/models/user.js'));
loopback.Change = require('../common/models/change');
loopback.Change = createModel(
require('../common/models/change.json'),
require('../common/models/change.js'));
loopback.Checkpoint = createModel(
require('../common/models/checkpoint.json'),

View File

@ -960,7 +960,10 @@ PersistedModel.enableChangeTracking = function() {
}
PersistedModel._defineChangeModel = function() {
var BaseChangeModel = require('./../common/models/change');
var BaseChangeModel = loopback.Change;
assert(BaseChangeModel,
'Change model must be defined before enabling change replication');
return this.Change = BaseChangeModel.extend(this.modelName + '-change',
{},
{