Skip to content
Merged

2.0 #276

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
4be3395
Add Change model
ritch Jan 26, 2014
1a13a8d
Add Checkpoint model and Model replication methods
ritch Jan 26, 2014
2582c3f
Add replication example
ritch Jan 28, 2014
a0e595d
Add model tests
ritch Jan 28, 2014
cc49d67
Add Change model
ritch Jan 26, 2014
e3d8005
Add Checkpoint model and Model replication methods
ritch Jan 26, 2014
ab8d1ae
Add replication example
ritch Jan 28, 2014
13f6738
Add model tests
ritch Jan 28, 2014
0bf7af1
fixup! rename Change.track => rectifyModelChanges
ritch Feb 5, 2014
867e3ca
fixup! Assert model exists
ritch Feb 5, 2014
e86a00d
Merge branch master
ritch Apr 15, 2014
b660f8a
Add replication e2e tests
ritch Apr 16, 2014
83e74ab
Merge
ritch Apr 16, 2014
e35309b
Fixes for e2e replication / remote connector tests
ritch Apr 30, 2014
69cd6a8
!fixup .replicate() argument handling
ritch Apr 30, 2014
918596f
Refactor DataModel remoting
ritch May 3, 2014
1c7527a
Add missing test/model file
ritch May 3, 2014
012f880
!fixup RemoteConnector tests
ritch May 3, 2014
e026a7f
fixup! unskip failing tests
ritch May 3, 2014
ae2fb9d
!fixup use DataModel instead of Model for all data based models
ritch May 3, 2014
f8b5fa1
All tests passing
ritch May 3, 2014
a3a6828
Move replication implementation to DataModel
ritch May 6, 2014
5bf1f76
!fixup Test cleanup
ritch May 7, 2014
9082214
Fix issues when using MongoDB for replication
May 10, 2014
4bab424
Add error logging for missing data
ritch May 12, 2014
1e2ad9f
Change#getModel(), Doc cleanup, Conflict event
ritch May 14, 2014
64ea805
Merge branch 'master' into feature/replication
ritch May 14, 2014
344601c
bump juggler version
ritch May 14, 2014
d875c51
Rework replication test
ritch May 16, 2014
2f21f4e
Rework replication test
ritch May 16, 2014
d58df51
Merge branch 'feature/replication' of github.com:strongloop/loopback …
ritch May 16, 2014
4d5e788
Add test for conflicts where both deleted
ritch May 16, 2014
558ea60
In progress: rework remoting meta-data
ritch May 16, 2014
eec7bdd
- Use the RemoteObjects class to find remote objects instead of
ritch May 19, 2014
2de33d4
Rework change conflict detection
ritch May 20, 2014
52eb72d
Remove un-rectify-able changes
ritch May 20, 2014
77bd77e
Ensure changes are created in sync
ritch May 20, 2014
1a8ba60
!fixup Mark DAO methods as delegate
ritch May 20, 2014
0c925f7
Depend on juggler@1.6.0
ritch May 20, 2014
d237ae5
Merge latest from master
ritch May 20, 2014
7a7f868
Add RC version
ritch May 20, 2014
7005c4b
2.0.0-beta1
ritch May 27, 2014
10bbfdc
2.0.0-beta2
ritch May 27, 2014
18fd61a
Merge branch 'master' into 2.0
May 28, 2014
0bb69f8
package.json: fix malformed json
May 28, 2014
ab0700a
2.0.0-beta3
May 28, 2014
566757b
Deprecate app.boot, remove app.installMiddleware
May 29, 2014
5aa8b36
Merge pull request #289 from strongloop/deprecate-boot-code
bajtos May 29, 2014
49380e4
Upgrade to Express 4.x
May 3, 2014
3c7cfca
Clean up the tests
May 29, 2014
bb0ddb2
Rename express-wrapper to express-middleware
May 29, 2014
d6ae28c
Update strong-remoting dep
May 30, 2014
c103057
Clean up express middleware dependencies
May 31, 2014
5b53da9
test: Remove forgotten call of `console.log()`
Jun 2, 2014
663e2d1
Merge pull request #293 from strongloop/feature/express-4.x
raymondfeng Jun 2, 2014
88a4bb4
Exclude express-middleware from browser bundle
Jun 3, 2014
26874fc
Make app.get/app.set available in browser
Jun 3, 2014
93a74f2
Merge pull request #299 from strongloop/feature/implement-app-setting…
bajtos Jun 3, 2014
ea5b9d1
Rename DataModel to PersistedModel
Jun 5, 2014
f844459
Add createModelFromConfig and configureModel()
Jun 5, 2014
71792b1
Merge pull request #302 from strongloop/rename-datamodel-to-persisted…
bajtos Jun 5, 2014
5f1c3a8
Merge pull request #304 from strongloop/feature/createModelFromConfig
bajtos Jun 6, 2014
51e977d
lib/loopback: fix jsdoc comments
Jun 6, 2014
1b11060
Remove assertIsModel and isDataSource
Jun 6, 2014
eac231d
refactor: extract runtime and registry
Jun 6, 2014
1de6325
test: add debug logs
Jun 6, 2014
63843b4
lib/registry fix jsdoc comments
Jun 9, 2014
56aab8d
Merge createModelFromConfig with createModel
Jun 9, 2014
09cc57c
registry: fix non-unique default dataSources
Jun 9, 2014
a90e24c
registry: export DataSource class
Jun 9, 2014
3f0fc09
Merge pull request #308 from strongloop/feature/cleanup-after-pr-304
bajtos Jun 10, 2014
b576639
Add loopback.version back
Jun 10, 2014
a9c35fa
Merge pull request #323 from strongloop/add-loopback-version-back
bajtos Jun 10, 2014
d21669b
Merge branch 'master' into 2.0
Jun 13, 2014
f80259a
Remove loopback-explorer from dev deps
Jun 13, 2014
98799c5
Merge pull request #328 from strongloop/remove-explorer-from-deps
bajtos Jun 13, 2014
d2517d8
Merge branch 'master' into 2.0
Jun 14, 2014
56c7a6b
Merge branch 'master' into 2.0
Jun 16, 2014
7316048
lib/registry: `getModel` throws, add `findModel`
Jun 16, 2014
75406f0
Merge pull request #331 from strongloop/make-get-model-throw-when-not…
bajtos Jun 16, 2014
5eca225
Fix remote method definition in client-server example
ritch Jun 19, 2014
b44dac3
Merge branch 'master' into 2.0
Jun 21, 2014
9eab7d6
Merge branch 'master' into 2.0
Jun 21, 2014
27a632c
Merge pull request #340 from strongloop/fix/client-server-example
ritch Jun 24, 2014
c896c78
Remove `app.boot`
Jun 25, 2014
41b826d
Allow peer to use beta2 of datasource-juggler (and future)
lchenay Jun 25, 2014
9c32a0f
Merge pull request #350 from strongloop/remove-app-boot
bajtos Jun 26, 2014
1daa93e
Merge pull request #349 from lchenay/patch-2
bajtos Jun 26, 2014
50816eb
Fix loopback in PhantomJS, fix karma tests
Jun 23, 2014
fb66bf5
package: upgrade juggler to 2.0.0-beta2
Jun 24, 2014
dd5360a
Merge pull request #344 from strongloop/fix-phantomjs-tests
bajtos Jun 26, 2014
f92d189
2.0.0-beta4
Jun 26, 2014
10d29c7
Merge branch 'master' into 2.0
Jun 27, 2014
8ea11ea
Merge branch 'master' into 2.0
Jul 1, 2014
be48a50
2.0.0-beta5
Jul 3, 2014
31ef639
checkpoint: fix `current()`
Jul 11, 2014
555d48f
Merge pull request #369 from strongloop/fix-replication
bajtos Jul 11, 2014
087c602
models/change: fix typo
Jul 15, 2014
da9b724
lib/application: publish Change models to REST API
Jul 15, 2014
b24d1e9
Merge pull request #374 from strongloop/fix-conflict-resolution
bajtos Jul 15, 2014
e18ee11
2.0.0-beta6
Jul 15, 2014
79f504a
Merge branch 'master' into 2.0
Jul 16, 2014
ff9bc10
Bump version
Jul 16, 2014
4e1d8c9
Merge branch '1.x' into 2.0
Jul 16, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
*.swp
*.swo
node_modules
dist
*xunit.xml
35 changes: 35 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Breaking Changes

# 1.9

## Remote Method API

`loopback.remoteMethod()` is now deprecated.

Defining remote methods now should be done like this:

```js
// static
MyModel.greet = function(msg, cb) {
cb(null, 'greetings... ' + msg);
}

MyModel.remoteMethod(
'greet',
{
accepts: [{arg: 'msg', type: 'string'}],
returns: {arg: 'greeting', type: 'string'}
}
);
```

**NOTE: remote instance method support is also now deprecated...
Use static methods instead. If you absolutely need it you can still set
`options.isStatic = false`** We plan to drop support for instance methods in
`2.0`.

## Remote Instance Methods

All remote instance methods have been replaced with static replacements.

The REST API is backwards compatible.
118 changes: 40 additions & 78 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*global module:false*/
module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-mocha-test');

// Project configuration.
grunt.initConfig({
// Metadata.
Expand Down Expand Up @@ -53,86 +55,39 @@ module.exports = function(grunt) {
}
}
},
karma: {
unit: {
mochaTest: {
'unit': {
src: 'test/*.js',
options: {
// base path, that will be used to resolve files and exclude
basePath: '',

// frameworks to use
frameworks: ['mocha', 'browserify'],

// list of files / patterns to load in the browser
files: [
'test/support.js',
'test/model.test.js',
'test/geo-point.test.js'
],

// list of files to exclude
exclude: [

],

// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots'],

// web server port
port: 9876,

// cli runner port
runnerPort: 9100,

// enable / disable colors in the output (reporters and logs)
colors: true,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: 'warn',

// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: [
'Chrome'
],

// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,

// Browserify config (all optional)
browserify: {
// extensions: ['.coffee'],
ignore: [
'nodemailer',
'passport',
'passport-local',
'superagent',
'supertest'
],
// transform: ['coffeeify'],
// debug: true,
// noParse: ['jquery'],
watch: true,
},

// Add browserify to preprocessors
preprocessors: {'test/*': ['browserify']}
reporter: 'dot',
}
},
'unit-xml': {
src: 'test/*.js',
options: {
reporter: 'xunit',
captureFile: 'xunit.xml'
}
}
},
karma: {
'unit-once': {
configFile: 'test/karma.conf.js',
browsers: [ 'PhantomJS' ],
singleRun: true,
reporters: ['dots', 'junit'],

// increase the timeout for slow build slaves (e.g. Travis-ci)
browserNoActivityTimeout: 30000,

// CI friendly test output
junitReporter: {
outputFile: 'karma-xunit.xml'
},
},
unit: {
configFile: 'test/karma.conf.js',
},
e2e: {
options: {
// base path, that will be used to resolve files and exclude
Expand All @@ -143,7 +98,8 @@ module.exports = function(grunt) {

// list of files / patterns to load in the browser
files: [
'test/e2e/remote-connector.e2e.js'
'test/e2e/remote-connector.e2e.js',
'test/e2e/replication.e2e.js'
],

// list of files to exclude
Expand Down Expand Up @@ -232,4 +188,10 @@ module.exports = function(grunt) {
// Default task.
grunt.registerTask('default', ['browserify']);

grunt.registerTask('test', [
process.env.JENKINS_HOME ? 'mochaTest:unit-xml' : 'mochaTest:unit',
'karma:unit-once']);

// alias for sl-ci-run and `npm test`
grunt.registerTask('mocha-and-karma', ['test']);
};
7 changes: 4 additions & 3 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"lib/loopback.js",
"lib/runtime.js",
"lib/registry.js",
{ "title": "Base model", "depth": 2 },
{ "title": "Base models", "depth": 2 },
"lib/models/model.js",
"lib/models/data-model.js",
"lib/models/persisted-model.js",
{ "title": "Middleware", "depth": 2 },
"lib/middleware/rest.js",
"lib/middleware/status.js",
Expand All @@ -19,7 +19,8 @@
"lib/models/application.js",
"lib/models/email.js",
"lib/models/role.js",
"lib/models/user.js"
"lib/models/user.js",
"lib/models/change.js"
],
"assets": "/docs/assets"
}
5 changes: 2 additions & 3 deletions example/client-server/models.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var loopback = require('../../');

var CartItem = exports.CartItem = loopback.DataModel.extend('CartItem', {
var CartItem = exports.CartItem = loopback.PersistedModel.extend('CartItem', {
tax: {type: Number, default: 0.1},
price: Number,
item: String,
Expand All @@ -22,8 +22,7 @@ CartItem.sum = function(cartId, callback) {
});
}

loopback.remoteMethod(
CartItem.sum,
CartItem.remoteMethod('sum',
{
accepts: {arg: 'cartId', type: 'number'},
returns: {arg: 'total', type: 'number'}
Expand Down
138 changes: 138 additions & 0 deletions example/replication/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
var loopback = require('../../');
var app = loopback();
var db = app.dataSource('db', {connector: loopback.Memory});
var Color = app.model('color', {dataSource: 'db', options: {trackChanges: true}});
var Color2 = app.model('color2', {dataSource: 'db', options: {trackChanges: true}});
var target = Color2;
var source = Color;
var SPEED = process.env.SPEED || 100;
var conflicts;

var steps = [

createSomeInitialSourceData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data'),
list.bind(this, target, 'current TARGET data'),

updateSomeTargetData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data '),
list.bind(this, target, 'current TARGET data (includes conflicting update)'),

updateSomeSourceDataCausingAConflict,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data (now has a conflict)'),
list.bind(this, target, 'current TARGET data (includes conflicting update)'),

resolveAllConflicts,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data (conflict resolved)'),
list.bind(this, target, 'current TARGET data (conflict resolved)'),

createMoreSourceData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data'),
list.bind(this, target, 'current TARGET data'),

createEvenMoreSourceData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data'),
list.bind(this, target, 'current TARGET data'),

deleteAllSourceData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data (empty)'),
list.bind(this, target, 'current TARGET data (empty)'),

createSomeNewSourceData,

replicateSourceToTarget,
list.bind(this, source, 'current SOURCE data'),
list.bind(this, target, 'current TARGET data')
];

run(steps);

function createSomeInitialSourceData() {
Color.create([
{name: 'red'},
{name: 'blue'},
{name: 'green'}
]);
}

function replicateSourceToTarget() {
Color.replicate(0, Color2, {}, function(err, replicationConflicts) {
conflicts = replicationConflicts;
});
}

function resolveAllConflicts() {
if(conflicts.length) {
conflicts.forEach(function(conflict) {
conflict.resolve();
});
}
}

function updateSomeTargetData() {
Color2.findById(1, function(err, color) {
color.name = 'conflict';
color.save();
});
}

function createMoreSourceData() {
Color.create({name: 'orange'});
}

function createEvenMoreSourceData() {
Color.create({name: 'black'});
}

function updateSomeSourceDataCausingAConflict() {
Color.findById(1, function(err, color) {
color.name = 'red!!!!';
color.save();
});
}

function deleteAllSourceData() {
Color.destroyAll();
}

function createSomeNewSourceData() {
Color.create([
{name: 'violet'},
{name: 'amber'},
{name: 'olive'}
]);
}

function list(model, msg) {
console.log(msg);
model.find(function(err, items) {
items.forEach(function(item) {
console.log(' -', item.name);
});
console.log();
});
}

function run(steps) {
setInterval(function() {
var step = steps.shift();
if(step) {
console.log(step.name);
step();
}
}, SPEED);
}
Binary file added favicon.ico
Binary file not shown.
Loading