Commit Graph

215 Commits

Author SHA1 Message Date
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
Miroslav Bajtoš 3df62444d6 Validate model on updateOrCreate (upsert).
Fix the implementation of updateOrCreate (a.k.a. upsert) to validate
the model before calling the connector.

In order to preserve backwards compatibility, validation errors are
only logged via console.warn by default.

The correct behaviour, where validation errors fail the updateOrCreate
operation, can be enabled via new model setting "validateUpsert".
2015-04-16 09:09:54 +02:00
Miroslav Bajtoš 3a51510119 Code cleanup in lib/dao.js
Rename callback argument "result" to "info" to make it consistent
with other places where we use "info" too.

Remove traling whitespace.
2015-04-01 18:25:04 +02:00
Raymond Feng 44e5ad1fef Merge pull request #549 from fabien/feature/hookstate-from-options
Allow passing in hookState from options
2015-03-30 14:35:34 -07:00
Fabien Franzen 1ab3d74ab5 Pass options in operation hooks context. 2015-03-30 18:03:42 +02:00
Pulkit Singhal 2891b5e5b3 check if id does not exist a bit more explicitly
if left as-is, ids with value of zero were treated as non-existent
2015-03-30 09:52:08 -05:00
Miroslav Bajtoš 093a307052 Merge pull request #542 from strongloop/feature/default-to-null
Add model setting "persistUndefinedAsNull"
2015-03-27 18:39:03 +01:00
Miroslav Bajtoš 9fd4c00225 Add model setting "persistUndefinedAsNull"
When the setting "persistUndefinedAsNull" is true,
the model will use `null` instead of `undefined` in
all property values.

 - Known optional model properties are set to `null` when no value
   was provided.

 - When setting model properties, `undefined` is always converted
   to `null`. This applies to both known (model-defined) properties
   and additional (custom, dynamic) properties.

 - The instance method `toObject()` converts `undefined` to `null` too.
   Because `toJSON()` calls `toObject()` under the hood, the change
   applies to `toJSON()` too.
2015-03-27 18:25:26 +01:00
Raymond Feng c340f416b1 Merge pull request #539 from fabien/fix/tiny-return-scope
Return scope object from DAO.scope
2015-03-27 09:26:50 -07:00
Miroslav Bajtoš a70a1b255a Code cleanup in updateAll/deleteAll
Rename the second callback argument to `info` to make its purpose more
clear. Fix jsdoc comments, note that these comments are NOT shown
on http://apidocs.strongloop.com/.
2015-03-26 19:01:25 +01:00
Fabien Franzen bbce005d12 Return scope object from DAO.scope 2015-03-26 15:39:26 +01:00
Miroslav Bajtoš f7dc6fab90 Fix regression in prototype.save
ffcaa4e7 added a "data" argument to the callback function, which
shadowed the original data with the data returned by a connector.
Not all connectors are returning a data object though, in which case
the model instance ("this" object) is updated with wrong values.

This commit fixes the problem by renaming the second callback argument
to "unusedData".
2015-03-23 08:34:21 +01:00
Raymond Feng 4ac227b052 Merge pull request #522 from strongloop/feature/enhance-id-comparison-for-updateAttributes
Enhance id comparision for updateAttributes
2015-03-20 11:06:57 -07:00
Raymond Feng 6a40a8a5e5 Enhance id comparision for updateAttributes
string/number and MongoDB ObjectID equality are now allowed.
2015-03-20 11:06:24 -07:00