Commit Graph

1560 Commits

Author SHA1 Message Date
Joost de Bruijn 7a4c6ca2f9 Fix query for related models (#1522) 2017-11-14 14:22:48 -05:00
zbarbuto 1d8603c491 Allow customizing embedded relation property (#1513) 2017-10-31 10:55:54 -04:00
Zak Barbuto 99cea38fd0 Allow passing null to base model ctor 2017-09-28 09:42:30 +09:30
Jürg Lehni 0ce1fa9f87 Add a better way to handle transactions 2017-09-06 07:10:57 +02:00
Joost de Bruijn f18d3487c6 validations: use new regex per evaluation (#1479)
The RegExp is cloned before executing the test. Fixing issue #1475.
2017-09-01 12:48:29 -04:00
Jürg Lehni 94a602d17e Transaction: Bind timeout to tx instance (#1484) 2017-08-31 11:10:17 -04:00
Rashmi Hunt 6c6df15286 Flag id as updateOnly when forceId is in effect (#1453)
* updateOnly, forceId changes

* support getUpdateOnlyProperties

* fixup! fix updateOrCreate in forceId mode

The contract of `updateOrCreate` is expecting a full object instance
to be passed to the callback.

The current implementation was creating an empty instance and
calling updateAttributes under the hood. As a result, the callback
was called with the attributes being updated only.

In order to preserve existing behaviour, we have to always build
a full initial instance by calling `findById`.

See the following discussion for more context:
https://github.com/strongloop/loopback-datasource-juggler/issues/966

* fixup! fix tests of upsert validation

* move forceId to model-builder

* remove TODO comment

* revert refactoring and test fixes

* Remove duplicate test

* change testcase names

* change to ModeClass.settingse

* forceId setup from datasource to model-builder

* fix inheritance of auto-generated forceId

* Fixed failing tests for auto change

* fixed a comment
2017-08-22 13:09:45 -07:00
loay 01b4c4a3a7 Catch err using Callback 2017-08-16 17:00:41 -04:00
Loay 80f3e93367 Merge pull request #1416 from strongloop/feature/fix-2364
Fix undefined properties in where
2017-08-09 13:54:28 -04:00
Tom Kirkpatrick 138b99c703 fix: support numbers in validatesFormatOf
Fix for #1437
2017-08-03 14:47:11 -04:00
Raymond Feng 03753b6fe2 Fix undefined properties in where
https://github.com/strongloop/loopback/issues/2364
2017-08-03 14:09:21 -04:00
ssh24 80f015c2d2 Honor backwards compatability with validate update 2017-08-03 11:50:44 -04:00
ssh24 9cd0108fc6 Fix update validation callback 2017-08-02 14:55:47 -04:00
ssh24 b1a0cb8c3b Validate updateAll 2017-08-02 13:24:21 -04:00
dmellonch 1b7c346bca Missing the option argument (#1426)
* Fix missing option arguments in scope.js

Added option arguments in find.relatedmodel
Added case test

* Add order filter in verify function

Fix for cloudant test
2017-08-01 14:15:21 -04:00
loay b1b2d5df0c Catch errors using cb 2017-07-24 14:08:58 -04:00
Diana Lau ff9b25a905 Merge pull request #1432 from simoami/master
#1386 Allow empty values when allowBlank is true
2017-07-20 11:23:54 -04:00
Jürg Lehni 4c9e91423f
Rename getAsync() methods to find() and get()
Keep getAsync() around for backward compatibility, but deprecate it
2017-07-20 14:48:29 +02:00
Simo Moujami 82a8e3d9a1 #1386 Allow empty values when allowBlank is true 2017-07-19 19:26:13 -04:00
Tetsuo Seto 4a6f0a4aa0 Fix the case where qWhere[idKey] is null 2017-06-09 09:33:22 -07:00
ssh24 98174251f1 Fix mixins/validatable docs 2017-06-06 14:21:49 -04:00
ssh24 ba1901b2a0 Fix updateAttributes cb
Allow pass through of the new data from the connector
Specifically for cloudant since updateAttributes changes the _rev
2017-05-29 15:32:32 -04:00
Rand McKinney 0a056adee4 Remove spurious extra options arg (#1390)
* Remove spurious extra options arg

* Remove space
2017-05-26 11:34:50 -07:00
Kevin Delisle 1b625228b9 include: remove JSDoc refs to recursive calls 2017-05-24 17:10:45 -04:00
Kevin Delisle d058244594 hooks: add JSDoc for .trigger 2017-05-23 12:12:11 -04:00
Kevin Delisle 117152d090 model-builder: JSDoc tidy-up 2017-05-23 10:31:38 -04:00
Raymond Feng 5a0b0270f3 Return promise for batch create 2017-05-19 16:16:52 -07:00
ssh24 54f67dc3b0 Use correct data on replace callback
Previously, it would just pass the old data
Pass the new data as cloudant updates the _rev property on CRUD
2017-05-18 17:03:21 -04:00
Raymond Feng c41487a1d1 Merge pull request #1371 from strongloop/exclude_prop
Handle excludeBaseProperties
2017-05-15 11:06:27 -05:00
Tetsuo Seto c07f46000d Support include rework for C* connector
- Remove supportNonPrimaryKeyIN
- Add C* Uuid in build call
- Implement smartMerge in scope.js
2017-05-12 22:43:21 -07:00
ebarault cfd3cdf535 Overall review of polymorphic relations
In #1298, the spec/doc for polymorphic relations was reviewed

**hasX relation**
- `type`: **hasMany**
- `as`: redefines **this** relation's name (optional)
- `model`: **modelTo**
- `polymorphic`:
  - typeOf `polymorphic` === `String`
    - matching **belongsTo** relation name
      - `foreignKey` is generated as `polymorphic + 'Id'`,
      - `discriminator` is generated as `polymorphic + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED** should display a warning,
            replaced by `selector`
    - `selector`: should match **belongsTo** relation name if the
                  latter is defined with {polymorphic: true}
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`:  A property of modelTo, representing the fk to
       modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`

---

**belongsTo relation**
- `type`: **belongsTo**
- `as`: redefines **this** relation's name (optional)
- `model`: **NOT EXPECTED**: should throw an error at
               relation validation
- `polymorphic`:
  - typeOf `polymorphic` === `Boolean`
      - `foreignKey` is generated as `relationName + 'Id'`,
      - `discriminator` is generated as `relationName + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED**: should display a warning,
            replaced by `selector`
    - `selector`:
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`: A property of modelTo, representing the fk to
                    modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`
2017-05-12 21:33:39 +02:00
rashmihunt 52f8fb3416 handle excludeBaseProperties 2017-05-10 12:03:42 -07:00
ebarault 79068d142b configurable model merge
The PR superseeds the existing deepMerge algorithm used to merge
settings of parent and child models with a new algorithm that allows
to specify the way each setting is merged or mixed-in.

This configuration of this algorithm uses a merge policy specification.
The `getMergePolicy()` helper of BaseModelClass can be used to ease
model merge configuration.

Next is presented the expected merge behaviour for each option.
NOTE: This applies to top-level settings properties

- Any
  - `{replace: true}` (default): child replaces the value from parent
  - assignin `null` on child setting deletes the inherited setting

- Arrays
  - `{replace: false}`: unique elements of parent and child cumulate
  - `{rank: true}` adds the model inheritance rank to array
    elements of type Object {} as internal property `__rank`

- Object {}:
  - `{replace: false}`: deep merges parent and child objects
  - `{patch: true}`: child replaces inner properties from parent

The recommended merge policy is returned by getMergePolicy()
when calling the method with option `{configureModelMerge: true}`.

The legacy built-in merge policy is returned by `getMergePolicy()`
when avoiding option `configureModelMerge`.
NOTE: it also delivers ACLs ranking in addition to the legacy
behaviour as well as fixes for settings `description` and `relations`

`getMergePolicy()` can be customized using model's setting
`configureModelMerge` as follows:
```
{
  // ..
  options: {
    configureModelMerge: {
      // merge options
    }
  }
  // ..
}
```

`getMergePolicy()` method can also be extended programmatically as
follows:
```
myModel.getMergePolicy = function(options) {
  const origin = myModel.base.getMergePolicy(options);
  return Object.assign({}, origin, {
    // new/overriding options
  });
};
```
2017-05-10 02:33:45 +02:00
Loay e3ce44a286 Merge pull request #818 from fullcube/fullcube/validatesUniquenessOf-case-insensitive
Fullcube/validates uniqueness of case insensitive
2017-05-05 10:41:42 -04:00
Loay 87dd44dd59 Fix assertion errors 2017-05-04 10:38:06 -04:00
Loay 84b55d8160 Update modelbaseclass api docs 2017-05-03 21:03:36 -04:00
Bram Borggreve c3629633de
Add caseInsensitive opt to validatesUniquenessOf 2017-05-01 17:26:16 -05:00
Kevin Delisle 5e80837424 Add DateString type
New type that preserves string input as a string, but ensures that
the string is a valid Date.

Additionally, provides a .toDate function to provide the Date
object representation of the string.
2017-05-01 12:28:59 -04:00
Loay ef61c8618a Update api documents 2017-04-27 16:28:43 -04:00
Kevin Delisle f7fe187120 Datasource documentation tune-up 2017-04-25 15:51:42 -04:00
paulussup e9ff88f453 Fix/geo null (#1334)
* fix check for null

* add tests

* fix for early return

* Allow check for null and non-existent value

Some connectors uses a non existent prop instead of allowing null
Modified test case to look if null exists or the prop is non existent

* Check for null value with geo near query

* Apply requested changes

* change test to two users and simplify

* check error first

* Fix simple query test case with null value

* BDD for connectors w//o null support
2017-04-24 19:28:11 -04:00
Diana Lau a488a71dbd replace exception thrown for invalid dates 2017-04-21 15:57:11 -04:00
Loay f1d10b47ce Fix forceId bug for updateOrCreate 2017-04-18 13:14:35 -04:00
Eric Barault 64f64caaff handle deep geo-near queries (#1314)
* handle deep geo-near queries (#1216)

    
a dedicated mongKey is added in geo.nearFilter for mongoDB
fixes geo min distance tests as filter now expects an array

* Fix for string geoPoints

* Add geo point handle for ibmdb connectors

* Handle geo-point type for cassandra connector
2017-04-13 17:05:05 -04:00
Kevin Delisle 00fe8fd59e Merge pull request #1313 from strongloop/revert-1216-fix/geo.nearFilter-deep
Revert ""Near" fix for where clauses"
2017-04-06 18:29:48 -04:00
Sakib Hasan befea83a76 Revert "handle deep geo-near queries (#1216)"
This reverts commit 6f88cf1930.
2017-04-06 17:45:04 -04:00
Joshua Chaitin-Pollak bb3812fbfb Allow `after save` hook to see count of records changed (#1231)
* `after save` hook allows count of records changed

* Fix PR linter
2017-04-06 12:02:34 -04:00
Corentin H 6f88cf1930 handle deep geo-near queries (#1216)
a dedicated mongKey is added in geo.nearFilter for mongoDB
fixes geo min distance tests as filter now expects an array
2017-04-06 08:25:04 -04:00
destillat fc2f66c514 Fix model def column name method (#1224) 2017-04-05 15:12:27 -04:00
Jonathan Sheely 21b08af7a3 Added notify flag for create and upsert (#1277)
* Added notify flag for create and upsert

* Code styling

* More code styling

* Added unit test for notify

* Fix PR linter
2017-04-05 13:23:26 -04:00
Waldemar Zahn ef143dc5eb Custom Table Names on rels (#1303)
hasAndBelongsToMany relation
2017-04-05 12:42:21 -04:00
Sakib Hasan 6a962583b0 Support multiple fk relations (#1308) 2017-04-04 18:23:43 -04:00
Thaer Abbas 57ead01624 #1261 Property name "constructor" is not allowed in 'Model' data (#1284)
* check if data has a constructor prop

* test data with no constructor

* test non function constructor

* test non function ctor message

* cleanup
2017-04-04 13:35:24 -04:00
Raymond Feng 1f995ec674 Use dataSource.connect to avoid duplicate connects 2017-04-04 10:19:58 -07:00
Raymond Feng 0a408476ec Fix in-mem connector file operation racing condition 2017-04-04 08:25:15 -07:00
Vincent Wen 8c93710963 make geo nearFilter support minDistance (#987) 2017-03-26 10:04:16 -04:00
Mikhail 68b93e1074 Disallow regexp string in arrays for coerce (#1279)
Disallow regexp arrays for coerce
2017-03-22 20:29:01 -04:00
Clark Wang c99441247c Fix - `_targetClass` on scope function (#1280)
Fix `_targetClass` on scope function when using hasManyThrough
relation with customized relation names and foreignKey/keyThrough.

This bug is cause by `_targetClass` uses the camel-case of
`relationName`(e.g.: if `relationName` is `bbb`, `targetClass`
would be `Bbb`), which is not exists.

This will also suppress "not exposed" warnings when generating
angular sdk, and generate end-points for this scope.
2017-03-22 17:06:36 -04:00
Nick Oikonomou b3a7bc521d Fixes #1275. `Include` filter transforms fields property into array. (#1276)
* Fixes#1275 Transform *fields* property into array

`Include` filter takes into consideration string property
'fields' and transforms it into an array containing this string.

* Added error handling for `include` filter.

* ExecTasksWithInterLeave now contains a try-catch block
 in order to catch any unexpected errors.

* LinkManyToMany now checks if *modelToIdName* exists on
 *target* before continuing.

* Added unit test for *include* with string fields
2017-03-22 10:03:36 -04:00
Dimitris 77c4cd7b01 Included models from include operations do not change defined `strict` model option (#1259)
* Fixes #1252

* Allowed setting of dynamic relation property

* Fixed tests to also consider other connectors
2017-03-20 19:48:57 -04:00
Dimitris 2bfc769c4d Using a filter with exclusion of a non existent property, removes an existing one (#1257)
* #fixes 1256

* Added missing check for returned error

* Fixed test to check proper fields in each doc
2017-03-20 19:18:48 -04:00
Sakib Hasan 3c7e398f6f Clean version of PR 1272 (#1273)
Able to filter out the properties given to a model instead
Of throwing an error
2017-03-20 18:10:01 -04:00
Diana Lau eb2cb315e6 FindOrCreate missing error callback 2017-03-20 10:32:09 -04:00
Dimitris 6f8ecfdf5c Fixes #1230 coerceArray converts empty Objects (#1269) 2017-03-20 10:05:11 -04:00
Kevin Delisle 248aaf0541 dao: catch errors on Model creation in find 2017-03-16 17:26:53 -04:00
Kevin Delisle a6c5802940 dao: catch sync errors on setAttributes
Wrap inst.setAttributes in try-catch to prevent synchronous errors
from crashing the application.
2017-03-16 17:26:53 -04:00
Loay 46318d2094 Update error message 2017-03-16 11:02:08 -04:00
jannyHou 7373e1ae31 Doc:Add option for discoverModelDefinitions 2017-03-14 21:51:30 -04:00
Rémi Bèges 11c2a19ad2 Add tests for validatesExclusionOf (#1248) 2017-03-08 10:24:18 -05:00
Rémi Bèges 9afaa9a66e Fix id update error message formatting
Error is raised when trying to update an id property while forceId
is set to true
2017-02-15 18:26:32 +01:00
Loay 9541bb5f15 Add proper statusCode for duplicate 2017-02-08 23:52:14 -05:00
Miroslav Bajtoš e8a977f55b Fix datasource to report connector-loading errors
Before this change, when resolving full connector path, all errors were
ignored. As a result, when the connector was installed but not
correctly built (e.g. loopback-connector-db2 which uses a native addon),
a very confusing message was reported by LoopBack.

In this commit, I am fixing the code handling `require()` errors
to ignore only MODULE_NOT_FOUND errors that contain the name
of the required module.
2017-02-03 20:29:11 +01:00
Miroslav Bajtoš d809260799 Upgrade eslint-config, fix new violations 2017-02-01 12:45:56 +01:00
Miroslav Bajtoš 121afda79b Fix option propagation in relation methods
- EmbedsMany.prototype.remove
 - EmbedsMany.prototype.add
2017-01-31 16:10:56 +01:00
Matteo Padovano 733ad1a024 Refactor logic of options.allowExtendedOperators
Implement logic to allowExtendedOperators options
per request, per Model and Datasource.
2017-01-30 00:05:56 +01:00
Loay 44a5a7ad81 Fix forceId validation error 2017-01-26 16:52:19 -05:00
Raymond Feng 0c76bd21b9 Upgrade dependencies to remove npm install warnings 2017-01-17 09:45:51 -08:00
Heath Morrison 2377792c22 Coerce array-like objects into arrays
The query-string parser used by express
https://github.com/ljharb/qs#parsing-arrays
limits the size of arrays that are created from query strings to 20
items. Arrays larger than that are converted to objects using numeric
indices.

This commit fixes the coercion algorithm used by queries to
treat number-indexed objects as arrays. We still maintain a strict
understanding of an "array-like object" to limit the opportunity for
subtle bugs. In particular, the presence of non-index keys is an
indication that the object was not intended to be interpreted as
an array.
2017-01-10 14:46:41 +01:00
Simon Ho 2320df1227 Refactor flush to deleteAll
- Rename `flush` to `deleteAll`
- Add `delete`
- Detect `delete/deleteAll` before running downstream test suites
- Fall back to unoptimized `deleteAll` when connector does not support
  `deleteAll` but supports `delete`
- Return 501 for connectors not supporting `delete` or `deleteAll`
2017-01-09 14:53:34 -08:00
Miroslav Bajtoš 454bf93aaf Upgrade eslint-config to 7.x
Also upgrade eslint itself to 3.x.
2017-01-06 13:33:54 +01:00
Brian Schemp cd94be2fb8 Throw error when model relation name is trigger
Defining a model relation with the name "trigger" causes the model not
able to insert records. No error is thrown when a model relation with
the name "trigger" is defined. Adding a check for the model relation
name "trigger" will now throw an error.
2017-01-02 17:09:14 +01:00
Simon Ho f38709b7cb Add flush operation to KVAO
Used to delete all keys (and values) associated to the current model.
2016-12-30 18:06:36 -08:00
Miroslav Bajtoš 0d862890e0 Fix HasOne.update to propagate options arg 2016-12-20 11:40:22 +01:00
Miroslav Bajtoš 779cf6a370 Honour allowExtendedOperators in "DAO.find"
Modify the coercion of filter.where to hounour "allowExtendedOperators"
and don't coerce property values of type object (extended operators).
2016-12-06 10:28:40 +01:00
Miroslav Bajtoš 0f7a567f18 Upgrade eslint & config to latest
- eslint ^3.11.1
 - eslint-config-loopback: ^6.0.0
 - fix linter errors (mostly no-undef)
2016-12-05 15:14:09 +01:00
Amirali Jafarian dd92b8d7e8 Merge pull request #1175 from BostjanPisler/patch-1
Fixed example for creating ValidationError
2016-12-03 10:59:12 -05:00
jannyHou 6c8e806bc8 Apply hasManyThrough filter on target model 2016-12-01 10:08:27 -05:00
Boštjan Pišler 93a739d612 Fixed example for creating ValidationError 2016-11-29 16:04:53 +01:00
Amir Jafarian 54d0f5b53d Add support for `loaded` hook
* Add support for loaded hook for DAO.find with near filter
2016-10-28 11:46:46 -04:00
Heath Morrison 266e9f5a9a Continue _coerce after logical operators 2016-10-25 23:09:46 +03:00
CerealGuy 662458dc2c Fix validateNumericality, nullCheck & add tests
validateNumericality didn't test if attributes value is a number
only if it's type is number.
Further nullCheck had a wrong testing order. It first checked if
value is null, later if blank. Also null check only used two equals,
not three. We don't use blank() anymore, testing if variable is
undefined should be fine too.
Added tests covering validateNumericality.
2016-10-15 10:59:22 +02:00
Nick Duffy a23076d3a8 Add ilike and nilike operators
Closes #633
2016-10-12 18:31:31 -06:00
Amir Jafarian e42b1327aa Fix JSDoc issue 2016-10-11 12:15:35 -04:00
Simon Ho b089b0d786 Fix linting errors
Trailing spaces in comments causing linter to fail. Errors introduced
at commit 9a1ef08495.
2016-09-29 19:28:02 -07:00
Rand McKinney 9a1ef08495 Update validations.js
Add doc of allowNull options property per #372.
2016-09-28 16:43:17 -07:00
Tim De Pauw be1d71f626 Support {defaultFn: 'shortid'} 2016-09-22 16:07:34 -07:00
Amirali Jafarian 66f27b9b83 Merge pull request #1094 from strongloop/newInstance_loade_updateAttributes
Add 'isNewInstance' for updateAttributes
2016-09-21 09:23:57 -04:00
David Cheung 373e038301 Merge pull request #1084 from strongloop/strict-mode-cleanup
[SEMVER-MAJOR] Strict mode cleanup
2016-09-20 08:24:31 -04:00
Amir Jafarian fec7742a69 Add 'isNewInstance' for updateAttributes
* Add 'isNewInstance' to loaded hook for updateAttributes
2016-09-19 16:56:15 -04:00
David Cheung 805db78e19 Strict mode now always return validationError
- Deprecation of strict:validate and strict:throw
- When strict mode is enabled, it will now always
return validation error (previous strict:validate)
2016-09-19 10:27:24 -04:00
Simon Ho 6796fac7f1 Add docs for KVAO 2016-09-16 17:03:33 -07:00
pponugo a39c0236bb Support nested queries for arrays
Enhance the built-in memory connector to correctly support nested
queries for arrays in addition to objects.

E.g. if "friends" is an array of objects containing "name", then
{ where: { "friends.name": "Jane" } } should match records containing
a friend called "Jane".
2016-09-07 13:33:57 +02:00
Simon Ho 96cd8ff56b Remove expired item before executing expire
The expire feature is falsely returning 204 instead of 404 because it is
not removing expired items before execution.
2016-09-01 21:18:40 -07:00
Amir Jafarian 2830062259 Disable `strict` for a few files
*Disable `strict` for a few files to disappear warnings
2016-08-26 09:54:31 -04:00
Amir Jafarian c17a490708 Fix CI introduced by `use strict` 2016-08-25 09:49:02 -04:00
Amir Jafarian aec678d252 Fix manually 2016-08-22 19:20:12 -04:00
Amir Jafarian aa6d28268b Auto-update by eslint --fix 2016-08-22 15:12:25 -04:00
Simon Ho 5b46484277 Merge pull request #1056 from strongloop/globalize-kv-mem-connector
Globalize KeyValue Memory connector
2016-08-19 12:58:31 -07:00
Miroslav Bajtoš 3b653a192b kvao: implement key filter 2016-08-18 09:59:56 +02:00
Miroslav Bajtoš 01ce7df60f kvao: add iterateKeys() and keys()
Add a core implementation of KVAO.iterateKeys() which returns an
AsyncIterator, inspired by
 - https://github.com/tc39/proposal-async-iteration
 - https://www.npmjs.com/package/async-iterators

This way we can safely iterate even large sets of data.

Also add KVAO.keys(), a sugar API converting the result of iterateKeys()
into a single array.
2016-08-18 09:59:56 +02:00
Simon Ho 8b28cb3993 Globalize KeyValue Memory connector 2016-08-17 18:22:17 -07:00
Sonali Samantaray 37541dd178 upsertWithWhere feature support in juggler DAO 2016-08-16 18:06:01 +05:30
Simon Ho 1c20cc83aa Add TTL for KeyValue related features 2016-08-11 17:12:36 -07:00
Miroslav Bajtoš b01df10eae Merge pull request #1039 from strongloop/fix/kv-memory-reference-error
kv-memory: fix crash in regular cleanup
2016-08-10 14:18:11 +02:00
Amir-61 1e57d4f316 Merge pull request #1034 from strongloop/err_connector_not_implements_replaceById
Return error if the connector does not implement
2016-08-09 14:01:58 -04:00
Amir-61 954c0df0c6 Merge pull request #1035 from strongloop/globalization_fixup
Fixup globalization
2016-08-09 10:44:06 -04:00
Amir Jafarian 327c785347 Return error if the connector does not implement
* Return error if the connector does not implement `replaceById`
2016-08-09 10:37:15 -04:00
Janny c4b2921977 Merge pull request #982 from strongloop/fix/auto-increment-db
forceId=true with auto-increment db
2016-08-09 10:02:36 -04:00
Miroslav Bajtoš 4978cd8089 kv-memory: fix crash in regular cleanup
Fix bug in "_setupRegularCleanup()" where the interval callback
was trying to access an object that has been garbage-collected
in the meantime.
2016-08-09 15:35:23 +02:00
jannyHou 8935b978f3 forceId=true with auto-increment db 2016-08-08 16:26:26 -04:00
Amir Jafarian d181fd0671 Fixup globalization 2016-08-08 15:34:41 -04:00
Miroslav Bajtoš 9ced20fdcc kvao: return 404 when expiring unknown key 2016-08-08 17:22:33 +02:00
Miroslav Bajtoš f15b4e2c86 Implement KeyValue API and memory connector
Models attached to a KeyValue connector get the following *static*
methods:

    Color.set(key, value);
    Color.set(key, value, ttl);
    Color.set(key, value, { ttl: ttl });

    Color.get(key);

    Color.expire(key, ttl);
2016-08-08 10:15:34 +02:00
Richard Pringle 0b62dd94ea Disallow bulk updateOrCreate. 2016-08-05 11:54:06 +02:00
Amir-61 c2a683bca4 Merge pull request #1007 from horiaradu/master
Optimize related model queries
2016-08-03 16:24:32 -04:00
Amir Jafarian a5429dc026 Update globalization 2016-08-03 14:48:35 -04:00
Amir Jafarian f2f9b4a6f8 Use g.f instead of utils.format 2016-08-03 10:47:40 -04:00
Horia Radu c3f62991c3 Optimize related model queries
No longer query for the related/included model when no results are
obtained in the first query.

fix:
https://github.com/strongloop/loopback-datasource-juggler/issues/1006
2016-08-01 20:23:08 +03:00
Amir Jafarian 4ce5b5d3a0 Support for globalization 2016-07-28 15:20:18 -04:00
Rand McKinney f1ed1ee023 Update include.js
Change doc comments to remove spurious API doc entry per #1008
2016-07-25 08:48:47 -07:00
Amir-61 20d8047198 Merge pull request #1009 from strongloop/declare_definition_in_destroy
Declare `definition`
2016-07-23 00:21:31 -04:00
Amir Jafarian 2143502a9d Remove unused variables in model.js 2016-07-22 17:23:09 -04:00
Amir Jafarian 8d4c577032 Declare `definition`
Declare `definition` in `BelongsTo.prototype.destroy`
2016-07-22 15:44:53 -04:00
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
Rand McKinney 45e14af4a9 Update validations.js
Fix API doc per https://github.com/strongloop/loopback/issues/2472
2016-06-29 16:13:44 -07:00
gunjpan 8076be2db1 Remove DataSource.registerType()
Result of compat flag cleanup.
- Current implementation has a wrapper
DataSource.registerType() for
ModelBuilder.registerType(). This removes
the wrapper to encourage use of original
method
2016-06-28 14:45:42 -04:00
RobinBiondi fbe58f7cf8 give options to validators #984 2016-06-24 14:44:43 -07:00
Gunjan Pandya e0a68289c5 Merge pull request #947 from strongloop/update-errormsg
[SEMVER-MAJOR] Throw Error for property names with dots
2016-06-24 16:50:00 -04:00
Amir-61 73bb418719 Merge pull request #960 from strongloop/fix/connection-err-msg
Update datasource.js
2016-06-17 11:29:26 -04:00
gunjpan 8117b0403f Throw Error for property names with dots
Result of Compat Flags Clenup.
Throws an error for property names with dots, instead
of a deprecation warning.
2016-06-09 17:50:59 -04: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
Dimitris Halatsis ea2266e453 Persist changes on parent for embedsOne
Allow direct save of changes on embedded model to be persisted on
parent document.

    Person.embedsOne(Address);
    Person.findById(someId)
      .then(function(p){
        var address = p.addressItem();
        address.street = 'new street'
        // This will now persist changes on parent document
        return address.save();
      })

[forward-port of #949]
2016-06-07 17:24:59 +02:00
Amir Jafarian 8f2077e344 Fix 2016-06-03 18:00:21 -04:00
Ritchie Martori 293a22fd31 Update datasource.js
Return a real `Error` message for the default `ping()` method.
2016-06-02 14:02:06 -07: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-61 8f347fbacb Merge pull request #954 from strongloop/callback_err_from_connector_UPSERT
Retun err for UPSERT if the connector returns err
2016-06-01 15:51:35 -04:00
Dimitris Halatsis b7ba73f1b1 ModelBuilder: add new setting strictEmbeddedModels
The setting controls the strict mode used for embedded property types,
for example the type of "address" property in this model definition:

    modelBuilder.define('TestEmbedded', {
      name: 'string',
      address: {
        street: 'string',
      },
    });
2016-06-01 13:12:50 +02:00
Amir Jafarian 82546fdf47 Retun err for UPSERT if the connector returns err 2016-05-31 22:17:23 -04:00
Alex Pitigoi 423db34bf3 fix error handling when applying undefined mixins 2016-05-31 12:24:04 -04:00