-
Notifications
You must be signed in to change notification settings - Fork 47
Conversation
This looks good at first pass, I'm just updating things and will rebase this on the changes to investigate further. Thank you. |
If you or anyone else have a better way to check if the Model is based on PersistedModel ... I would love to know :) |
I believe you can look at the |
…identify PersistedModel
I've added Model.settings.base check before the exist method for possible speed optimization. |
I am new to Strongloop/Loopback and just tried loopback-ds-timestamp-mixin. When I start my service, I get "TimeStamp mixin requires validateUpsert be false. See @clarkbw/loopback-ds-timestamp-mixin#10". Will this check in fix this issue or we must have validateUpsert set to false? Thank you! |
@margagn the pull removes the need to have validateUpsert set to false on PersistentModel based models |
@clarkbw anything I can help with to get the version 3.2.3 out? |
This doesn't appear to work for me. PUT to updateAttributes works as expected (created date not modified). Note: My models are based off a subclass of PersistedModel (not off PersistedModel directly). |
@mrfelton few questions:
|
Hi, Model Trip:
Model Passenger:
} Now, using prototype_updateById_passengers on Model Trips to update a singler Passenger instance, the createdAt date is refreshed anytime |
@ebarault I had the exact same issue. It's related to a totally different bug on juggler which events are not triggered correctly for embedded models. The fix for this right now (I have the exact same issue) is to save the father model and then add the embedded models using the father model id.
This way you can actually enable the mixin for embedded models even :) |
@clarkbw any updates regarding the possible merge? |
@ShaharHD, thanks for getting back,
did you mean something else? |
couple of ideas to try out:
and in
|
@ShaharHD : all config is ok, still does not work. i'm good to pass the createdAt value when updating for now. |
@ShaharHD : loopbackio/loopback-datasource-juggler#516 |
@ebarault 👍 createdAt is updated on the embedded models because it doesn't have the model to reference to when referencing this. I actually have some more modifications planned. for example:
Further more, I did talk with the StrongLoop sales guy, more than once regarding this issue, that the loopback people are ignoring a few troublesome issues - without even acknowledging them. In any case, I'm still waiting on @clarkbw for some response, but I'm guessing he's pre-occupied for now, so my projects are actually referencing my git branch. |
did you mean updatedAt instead of createdAt? These were actually causing me Oh yeah you're right, i had a few occasions to comment on these kind of 2016-03-08 23:19 GMT+01:00 Shahar Hadas [email protected]:
|
@ebarault yep. my bad. updatedAt - in my testing I disabled validate at the relations to bypass some problems. |
Ok, I'm back and reviewing everything now. Sorry I got caught up with other things. |
I created #20 to update the module to the latest build system. This is the pain of trying to use "latest" in all your |
@clarkbw you need me to do catchup on my branch? |
Ok, I didn't notice this before but it appears that your changes were made to the generated files in the main directory and not the files in the I'll try to make your changes right now in a new branch to run the tests and will report back. |
My bad ... didn't read that... just went ahead and fixed it :) |
No, thank you for this awesome work! 👍 And again, sorry I've had such crappy turn around time. 😐 |
As I said before, I actually have some more modifications planned. for example:
You did most of the work here ... I just adopted it to overcome some of LB shortcomings :) |
Would be interesting if you can possibly grab it from the instance value without a lookup.
I've struggled with this because the reason you do an upsert is for performance, otherwise you could do your own select and update || create. When we take away performance the upsert becomes syntax sugar, which is possibly useful but doesn't feel like a good default. If this was a run time option developers could choose to take the perf hit as desired.
So pull the validation internally instead of using the juggler? Feels like it will require lots of tests, I'll be interested to see how you do it. |
Ok, I created https://github.com/clarkbw/loopback-ds-timestamp-mixin/tree/pr/18 with all of your changes in the correct es6 directory however the tests still fail. I'm looking into it but it appears that the If you want to take the changes I organized and apply them to your current branch you could continue working from there. It's probably best if you update your code, rebase to master and force push. You could open a new PR with the updated code branch I made if that's easier. I'll do a little more digging as well but something is off with the upserts, the timestamps are no longer the same. Tests like this one fail, https://github.com/clarkbw/loopback-ds-timestamp-mixin/blob/master/test/test.js#L52-L64 |
Thanks, I'll work on this on the weekend probably. |
Hey guys, any updates on this? |
I'm still trying to clear some time to work on this. I'll probably do it this weekend. |
Cool, just wanted to know if someone was working on this :) |
I've added an option for |
@ShaharHD I took some of your better error reporting but struggled to understand the purpose of the rest of your code. We can talk about it more here, but for now with the option to be able to validate most of the concerns here should be resolved. |
Possible fix for #10 , #11
Maybe even #17 (someone can test?)
#12 will be solved once loopbackio/loopback-datasource-juggler#516 will be incorporated.
The solution I revised follow this:
On the init phase:
On the hook: