Commit Graph

228 Commits

Author SHA1 Message Date
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
Bryan Clark 342bc2f782 prevent upsert overwriting default values with applyDefaultValues option
Creates a new applyDefaultValues option on the Model constructor
defaulting to true, the current behaviour.

Updates the dao module to pass `{ applyDefaultValues: false }` to the
Model constructor during the updateOrCreate method when we assume an
update is happening.
2015-07-14 09:08:10 -07:00
Raymond Feng eb20eebe95 Fix the regression for date conversion 2015-07-03 09:29:26 -07:00
Raymond Feng 4206088fbc Fix the regexp value for like/nlike 2015-07-02 23:22:36 -07:00
Raymond Feng 542afefb1d Make sure operator/options are honored 2015-07-02 11:27:33 -07:00
Raymond Feng 50ac143cea Merge pull request #652 from strongloop/feature/fix-objectid-coercion
Fix coercion from ObjectID to String
2015-07-02 10:21:03 -07:00
Raymond Feng 506abf134e Merge pull request #642 from rus0000/rus0000-patch-1-fix-updateOrCreate-transaction
Fix updateOrCreate transaction propagation
2015-07-02 10:17:12 -07:00
Raymond Feng eb6fa410fe Fix coercion from ObjectID to String 2015-07-01 14:58:14 -07:00
Miroslav Bajtoš 293240d752 Merge pull request #599 from PradnyaBaviskar/issue-441
Add new hook 'loaded'
2015-06-24 16:35:50 +02:00
Rus1 17cac79b09 Fix updateOrCreate transaction propagation 2015-06-23 19:14:36 +03:00
Rus1 ca8012ba0a Fix promise chaining in case of error 2015-06-23 19:08:46 +03:00
Pradnya Baviskar 20cf67d798 Add new hook 'loaded' 2015-06-23 12:04:46 +05:30
Pradnya Baviskar 3b0e77cb0a Add new hook 'persist' 2015-06-10 16:19:13 +05:30
Raymond Feng 966bb56c31 Enhance fieldsToArray to consider strict mode 2015-05-19 22:32:03 -07:00
Raymond Feng 93a0342099 Add an optional `options` argument to relation methods 2015-05-16 11:52:17 -07:00
Raymond Feng 670a6e740d Add transaction 2015-05-16 11:52:17 -07:00
Raymond Feng 5ef444e45d Conditionally pass options to connector CRUD methods 2015-05-13 09:36:45 -07:00
Fabien Franzen df7d221f31 Pass-through options from save to create 2015-05-10 10:44:22 +02:00
Miroslav Bajtoš 9bc79d2366 dao: support validateUpsert:false
- validateUpsert:true reports validation errors back to the callback
 - validateUpsert:false does not call `isValid()` at all
 - any other value report validation errors via `console.warn`
2015-05-05 08:24:08 +02:00
Miroslav Bajtoš b642d52fbe Merge pull request #565 from strongloop/feature/validate-upsert
Validate model on updateOrCreate (upsert).
2015-04-17 17:20:55 +02:00
Raymond Feng 988a929577 Extend findById to accept an optional filter object 2015-04-16 09:06:53 -07:00