Commit Graph

248 Commits

Author SHA1 Message Date
Miroslav Bajtoš 699e0587d1 Ensure stable order of items in DAO.find()
When post-processing result of find operation, use "async.map"
instead of "async.each + array.push" to ensure the order of items
is preserved.
2016-07-13 14:55:49 +02:00
RobinBiondi fbe58f7cf8 give options to validators #984 2016-06-24 14:44:43 -07:00
Amir Jafarian 7a8803cb38 Give warning if PK is changed in hooks
* Give warning if PK is changed in `before save` and `loaded`
 operation hooks for replaceById
2016-06-08 11:56:19 -04:00
Candy 3daca1e960 Remove model events 2016-06-08 10:27:05 -04:00
Amir Jafarian cae44f0458 Fix error message
*Fix error message when PK is changed in `replaceById`
2016-06-01 16:16:35 -04:00
Amir Jafarian 82546fdf47 Retun err for UPSERT if the connector returns err 2016-05-31 22:17:23 -04:00
Amir Jafarian d9a3f6226a Fix incompatibility between different connectors
* Fix incompatibility for replace methods between different connectors.
2016-05-27 13:45:24 -04:00
Sequoia McDowell ae7a5df47b Document promise support for DAO::find
It was previously completely undocumented. There are additional methods that add promises but I figure accurately documenting some is better than none. :)
2016-05-11 09:58:22 -04:00
Miroslav Bajtoš 8ad53a4c0e DAO.create: don't return the instance
Simplify DataAccessObject.create() and stop returning the
instance/array of instances. Users should always use callback (or
returned promise) to get the instance(s) created.
2016-04-29 14:16:06 +02:00
Miroslav Bajtoš c7f34c3452 eslint config 2.0 + remove extra empty lines
Upgrade eslint-config-loopback to ^2.0.0.

Remove extra empty lines to make `npm run lint` pass again.
2016-04-19 16:11:43 +02:00
Amir Jafarian 4e6351b856 Fix `forceId` check for `replaceById` 2016-04-14 15:05:56 -04:00
Amir Jafarian e9afb46eda Fix `notify` bugs for `find` 2016-04-13 13:34:51 -04:00
Amir Jafarian 4bb284bb60 Define `patch` aliases
*Define `patchOrCreate` as an alias for `updateOrCreate`
*Define `PatchAttributes` as an alias for `updateAttributes`
2016-04-12 13:40:01 -04:00
Miroslav Bajtoš 27c6279d6c fix remaining eslint issues 2016-04-05 15:25:34 +02:00
Miroslav Bajtoš 39e04a1756 eslint --fix 2016-04-05 15:25:34 +02:00
Ryan Graham c467b43c38 Insert copyright headers 2016-04-04 18:14:03 -07:00
Amir Jafarian 2281e95940 Implementtaion of replace
This includes:
*implementation of replaceAttributes
*implementtaion of replaceOrCreate
2016-02-03 16:06:35 -05:00
Amir Jafarian ef232eae0a Fix conversion for `updateAttributes` 2016-02-03 12:04:51 -05:00
Amir Jafarian 550cfa2a86 Refactor `updateAttributes` 2016-01-25 10:56:27 +01:00
Amir Jafarian a5150265ec Fix a bug when validation is off for findOrCreate 2016-01-08 16:47:38 -05:00
Miroslav Bajtoš e9899a93cf Enhance "persist" hook in DAO.updateOrCreate
Report `ctx.isNewInstance` when the connector provides this info.
2015-12-18 16:08:38 +01:00
Miroslav Bajtoš fd9bef4aa7 Enhance "persisted" hook in DAO.updateAttributes
Add `isNewInstance:false` to the context reported by
DAO.updateAttributes()
2015-12-18 16:08:01 +01:00
Miroslav Bajtoš 3028329126 "loaded" hook in DAO.find: ctx.data, not instance
Fix the implementation od DAO.find to provide "ctx.data" to the
"loaded" hook.
2015-12-18 15:54:35 +01:00
Miroslav Bajtoš 80c3bd9d41 Merge pull request #752 from ernie58/optionalValidation
make automatic validation optional
2015-12-04 17:03:28 +01:00
Bert Casier 0f3f27af51 Make automatic validation optional
Make automatic validation optional on all CRUD methods in a loopback
model. This can be done in 2 ways

- set `automaticValidation` in the model settings

- set `validate` on the options passed when calling the crud methods

The options take precedence on the model setting.
By default the automatic validation remains true to be backwards
compatible
2015-12-03 16:34:25 +01:00
Abe BW 0334766490 fixed a bug where an error was sent to the updateAttributesCallback and then ignored 2015-11-23 14:07:35 -05:00
Clark Wang b1b36ed44e fix typo 2015-11-04 14:58:28 +08:00
Clark Wang b993fb9466 fix global leak that mocha complains
Signed-off-by: Clark Wang <clark.wangs@gmail.com>
2015-11-04 14:19:47 +08:00
Raymond Feng d0072b68a1 Merge pull request #739 from mdartic/master
Fix filtering relations of a model with an order specified
2015-10-28 08:38:03 -07:00
Federico Rampazzo 2de499ccb0 Added missing callback when a model is not found 2015-10-28 09:15:32 +00:00
mdartic 7c22db6ea7 Filtering relations of a model with an order specified 2015-10-16 18:21:04 +02:00
Ryan Schumacher 94c3f9a432 Ability to define normalization of undefined query
Add datasource and model setting `normalizeUndefinedInQuery`
to determine how it will handle undefined values. Options:

- nullify : converts undefined to null
- throw : throw an error on undefined value
- ignore : strip the key where undefined value is found

The default operation is to strip the key.
2015-10-07 09:26:09 -07:00
James Cooke 6dac956cf8 findByIds would fail when an array of 0 length was passed as its first argument 2015-09-23 16:27:41 +01:00
Simon Ho 57a9c40e16 Fix primary key checks 2015-08-27 13:59:43 -07:00
Simon Ho cd71a37bfa Relax id requirement for basic query operations 2015-08-20 02:57:53 -07:00
Raymond Feng f5270c39c5 Refactor idEquals to utils 2015-08-17 12:49:38 -07:00
Simon Ho d14721656f Merge pull request #691 from strongloop/do-not-coerce-regexp-to-string
Do not coerce RegExp objects to strings
2015-08-14 09:14:05 -07:00
Simon Ho e7e074f97b Do not coerce RegExp objects to strings
Queries like `{where: {name: /John.*/i}}` should work. Notice there is no
`regexp` operator (ie. `{where: {name: {regexp: /John.*/i}}}`).
2015-08-13 16:16:48 -07:00
Fabien Franzen 2120e53f7f Indicate result of destroyById/protototype.destroy
Return `info.count` to the callback to indicate whether the model
instance was deleted or not. When Model's `settings.strictDelete`
is true, return 404 error when the model instance was not found.
2015-08-10 17:38:46 +02:00
Raymond Feng 4d7bfc94cd Fix error handling 2015-07-29 10:21:47 -07:00
Raymond Feng ce57234d5e Merge branch 'issue656-findLoadedAsync' of https://github.com/PradnyaBaviskar/loopback-datasource-juggler into PradnyaBaviskar-issue656-findLoadedAsync 2015-07-29 07:33:21 -07:00
Simon Ho 68dc1d821f Remove try/catch from find function 2015-07-28 17:40:14 -07:00
Simon Ho b2b5a0d920 Merge pull request #665 from strongloop/add-regex-support
Add support for RegExp operator
2015-07-28 15:22:02 -07:00
Simon Ho b8f1598723 Add support for regex operator 2015-07-27 15:11:53 -07:00
Pradnya Baviskar de0ca3c61f Async 'loaded' hook for find 2015-07-27 18:58:29 +05:30
Raymond Feng b08b6dd954 Merge pull request #650 from PradnyaBaviskar/issue-649
Fix 'persist' hook for updateAttributes()
2015-07-23 08:27:07 -07:00
Pradnya Baviskar 8a20e07b3d Fix 'persist' hook for updateAttributes() 2015-07-23 15:25:50 +05:30
Fabien Franzen a94993c097 Don't enforce strictness if allowExtendedOperators: true (MongoDB) 2015-07-22 17:09:04 +02:00
Fabien Franzen c7caa0a7c1 Take strict: validate and throw settings into account 2015-07-21 13:33:42 +02:00
Fabien Franzen 8b06a9d39d Filter attributes when strict: true 2015-07-20 11:59:07 +02:00