-
Notifications
You must be signed in to change notification settings - Fork 110
Conversation
Can you please make the commit message of 7a545e7 more explanatory? Change tracking was already enabled. |
7a0a761
to
87f43a9
Compare
@bajtos Running
Do you know what this means? |
4e7f5ec
to
e1e9fb4
Compare
Also getting: Running "mochaTest:server" (mochaTest) task
Todo
New todo empty data
POST /api/Todos
✓ should be allowed
✓ should have statusCode 200
1) should respond with a new todo # this is failing
...
1 failing
1) Todo New todo empty data POST /api/Todos should respond with a new todo:
AssertionError: null == true
at Context.<anonymous> (server/test/todo.test.js:23:9) For some reason, the test is returning an actual mongo id (might be something to do with the "before save" operation hook). |
9e71a07
to
00e1980
Compare
@@ -19,7 +19,8 @@ describe('Todo', function() { | |||
assert.equal(this.res.statusCode, 200); | |||
}); | |||
|
|||
it('should respond with a new todo', function() { | |||
it.skip('should respond with a new todo', function() { | |||
console.log(this.res.body.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.res.body.id
returns an actual MongoDB id instead of the t-math id
. Any idea why this is happening?
922dac1
to
de3fc30
Compare
See strongloop/loopback-boot#124
No idea.
I think that's because all Todo ids are initialized with a GUID value - see |
de3fc30
to
15f3a1a
Compare
RemoteTodo, | ||
since.push, | ||
function pushed(err, conflicts, cps) { | ||
console.log('LR', arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting [Error: Invalid URI "/api/Todos/checkpoint", undefined, undefined]
here also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the URL "/api/Todos/checkpoint" available in the explorer?
Please create a new RemoteTodo model per the instructions in docs and use it instead of the base Todo model here.
- var RemoteTodo = client.models.Todo;
+ var RemoteTodo = client.models.RemoteTodo;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem is caused by the fact that your RemoteTodo (=base Todo ATM) has change tracking enabled, thus it's trying to rectify changes via REST API. That's why you need to create a new subclass RemoteTodo which will not track changes but still provide the replication API. See the docs for more details.
For each replicated model, create two new client-only subclasses:
- A local model that will use local storage to persist the changes offline
- A remote model that will be connected to the server and used as a target for replication. This model will have change tracking disabled (because the server is already handling it) and enable only the replication REST API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15f3a1a
to
e808aed
Compare
RemoteTodo, | ||
since.push, | ||
function pushed(err, conflicts, cps) { | ||
if (err) throw err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still getting Invalid URI "/api/Todos/checkpoint"
here. Do you see any obvious changes I may have missed? FYI, I just copied/pasted all the code from the confluence docs this time.
I see, will bump
Going to skip the test then.
I see. So it's possible this initialization is causing that one test to fail then. Anyways, I'm skipping the test, so its not blocking what we're trying to do anyways. |
@@ -2,6 +2,6 @@ var GLOBAL_CONFIG = require('../../global-config'); | |||
|
|||
module.exports = { | |||
remote: { | |||
url: GLOBAL_CONFIG.restApiUrl | |||
url: 'http://localhost:3000' + GLOBAL_CONFIG.restApiUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out the problem. This might be a bug, but you need to add the fully qualified URL and domain for things to work properly. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See strongloop/strong-remoting#200
The host + port must not be hard-coded here. Check the way how GLOBAL_CONFIG is constructed and modify the code to produce a full URL, so that datasources.local.js
can stay unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that host + port value must be synchronized with settings in server/config.json
. When you change port in server/config.json
, the client app should automatically pick it up after rebuild via grunt.
No no, don't skip the test, fix it instead. As you can see, it's checking the format of the id property: assert(this.res.body.id.match(/t-\d+/)); Since you are no longer generating ids as Or simply remove |
57eeea2
to
f540e99
Compare
Updated the test to check for proper GUID format. |
f540e99
to
b4ee01c
Compare
64c1617
to
5729f88
Compare
@bajtos Please code review. If you see anything obvious that needs fixing, please add it to this PR yourself as I will be away for 2 weeks. If there is no hurry to merge this, then I can finish it up when I'm back. As for the easy-to-read GUID feature, I created a separate issue at #62 and will work on it after I'm back. |
@@ -1,6 +1,7 @@ | |||
{ | |||
"remote": { | |||
"connector": "remote" | |||
"connector": "remote", | |||
"url": "/api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, this value is overriden by datasources.local.js and thus not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed url
k/v.
Assigning back to @bajtos , Simon on PTO |
Reassigning back to Simon, offline sync is not urgent now. |
@superkhau @bajtos is this good to go? |
5729f88
to
d1345fa
Compare
@bajtos Code review again please. |
@@ -23,17 +23,32 @@ module.exports = function(client) { | |||
}; | |||
|
|||
// setup model replication | |||
var since = {push: -1, pull: -1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: AFAIK, we use Node coding style where curly braces are surrounded by spaces: { push: -1, pull: -1 }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a style guide for the style you describe? I've just been following the Google one at https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a style guide for the style you describe?
https://strongloop.atlassian.net/wiki/display/SL/Code+Style+Guide
We have had some discussions about spacing in array/object initialisation - see https://strongloop.atlassian.net/wiki/display/SL/Code+Style+Guide?focusedCommentId=21430339#comment-21430339
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY, I will take a look. ;)
Nice! I left one more comment, feel free to ignore it. The rest LGTM. |
- Enable "strict" and "persistUndefinedAsNull" flags for the Todo model - Correctly store & send since checkpoints - Remove deprecated events with operation hooks - Implement error handler for change-tracking errors - Rework conflict resolution in `client/ngapp/scripts/controllers/todo.js` to use the new API
d1345fa
to
a5dd541
Compare
…-changes Refactor with Sync 1.0 changes
Connect to strongloop-internal/scrum-loopback#214