Commit Graph

1054 Commits

Author SHA1 Message Date
Tom Kirkpatrick 1ebad655e4 test: call true/false in isValid checks 2017-08-03 14:47:11 -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
ssh24 aec1179a30 Sort arrays before testing
Sorting the array so the ordering is the same
2017-08-02 10:45:36 -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
biniam 59b3ac22a8 use connector flag throughout tests 2017-07-26 16:18:30 -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
Janny 6a1b55568c Skip imcompatible tests (#1420)
* Skip imcompatible tests
2017-07-18 15:20:21 -04:00
Janny b9129e6973 Run juggler tests for Cloudant (#1414) 2017-07-11 14:56:39 -04:00
Tetsuo Seto 4a6f0a4aa0 Fix the case where qWhere[idKey] is null 2017-06-09 09:33:22 -07:00
Kevin Delisle 828a71e576 test/helpers: annotate skipped tests
Differentiate between tests skipped by feature flags, and those
manually marked as skipped.

Tests that use the bdd.describe and bdd.it helper functions
will be marked as [UNSUPPORTED] if they are conditionally disabled.
2017-06-07 14:05:48 -04:00
ssh24 e791e9006c Apply iteration on the model object 2017-05-26 18:49:54 -04:00
ssh24 825fa3171c Fix count of properties 2017-05-23 22:17:50 -04:00
Raymond Feng 5a0b0270f3 Return promise for batch create 2017-05-19 16:16:52 -07:00
Raymond Feng c41487a1d1 Merge pull request #1371 from strongloop/exclude_prop
Handle excludeBaseProperties
2017-05-15 11:06:27 -05:00
Tetsuo Seto ef08458e8d Remove unnecessary tests for adhocSort !== false 2017-05-15 03:04:09 -07:00
Tetsuo Seto aa3f5fa4f4 Fix the test case to avoid duplicate userId 2017-05-14 19:17:32 -07: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 45bf569ec4 fix assert, make the test case more clear 2017-05-12 11:47:50 -07:00
rashmihunt fed0396d9e code review, better asserts 2017-05-11 09:59:39 -07:00
rashmihunt 5aee1fe17e test case to exclude base props 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
Kevin Delisle 156b638518 Merge pull request #1356 from strongloop/datetype-allow-strings
Add DateString type
2017-05-02 14:48:50 -04:00
Janny 5d10c72664 create sequence for nosql id (#1354)
* create sequence for nosql id
2017-05-02 13:35:57 -04:00
Bram Borggreve c3629633de
Add caseInsensitive opt to validatesUniquenessOf 2017-05-01 17:26:16 -05:00
Loay 6cfdcc0128 Fix order of query results 2017-05-01 16:10:55 -04: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
Kevin Delisle 8e97385a8f datatype.test: use predefined date
Some databases are storing the value in UTC (not ISO) format,
and truncating the values. Even though this is technically
unavoidable, it does fail strict string equality.
2017-04-28 15:40:19 -04:00
Andrew McDonnell 238175b4bd Added unit tests specific to DateType where null (#1349)
* Added unit test for DateType where null

* BDD for connectors w/o null support
2017-04-25 13:05:55 -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 3c19beacbb Add test case using updateAttributes 2017-04-18 13:50:57 -04:00
Loay f1d10b47ce Fix forceId bug for updateOrCreate 2017-04-18 13:14:35 -04:00
loay 1cdb431ae2 Fix relations test case 2017-04-14 03:35:46 -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
Loay 9dc5430652 Unskip test case 2017-04-12 12:54:30 -04:00
Tetsuo Seto c1598584d8 Make tests work for other connectors as well as C*
Adjust getSchema calls
Compare ids as strings
Run tests when explicitly set to true
2017-04-12 09:11:42 -07:00
Tetsuo Seto 696e4cfa80 Remove debugger statement 2017-04-07 15:05:15 -07:00
Tetsuo Seto 0f9100f185 Fixup test support for Cassandra connector 2017-04-07 14:11:33 -07:00
Tetsuo Seto ead1fb2965 Add test support for Cassandra connector 2017-04-07 11:10:47 -07: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
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
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
Matteo Padovano 957058e2d4 remove equality value for user defined id (#1293)
Some connector, like arangodb, not support id as Number.
When `forceId` is set to true and id is set `Model.isValid`
report error and the field id is not coerced.
2017-04-04 12:45:23 -04: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
Dimitris 6f8ecfdf5c Fixes #1230 coerceArray converts empty Objects (#1269) 2017-03-20 10:05:11 -04:00
Matteo Padovano 1f52d23d67 override collection name for arangodb (#1243)
Add collection name settings for arangodb database.
Required to pass common tests included in community connector
2017-03-20 09:01:16 -04:00
Rémi Bèges 55128f0c9b Add test coverage for `validatesInclusionOf` (#1249)
* Fix indentation

* Improve tests formatting

* Use instanceof and should.match
2017-03-18 06:50:10 -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 557a2e48d2 Fix Order query test case 2017-03-15 14:45:36 -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
jannyHou 8b1100e3ed Add test case for all connectors 2017-02-14 14:01:44 -05: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
Loay 4bd03a25f2 Ensure replaceById returns 404 when id not found 2017-02-01 11:57:54 -05:00
Miroslav Bajtoš d809260799 Upgrade eslint-config, fix new violations 2017-02-01 12:45: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
Miroslav Bajtoš b5d03b845f Add two basic tests for "inq" operator 2017-01-19 13:33:39 +01:00
Simon Ho 9a0d34a7a3 Add missing return for KVAO delete all 2017-01-13 00:19:10 -08:00
Simon Ho 188fb10c96 Add missing return in KVAO keys test suite 2017-01-11 19:35:37 -08:00
Simon Ho 0b93c5c6dd Detect deleteAll support in KVAO tests
Clear CacheItem data between tests if connector supports `deleteAll`.
Tests fail with 501 if this check is not used.
2017-01-11 16:30:33 -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
Simon Ho d095cc1161 Merge pull request #1194 from strongloop/1237/fix-block-padding
Fix block padding
2016-12-21 14:17:42 -08:00
Miroslav Bajtoš 2ca081216b Fix eslint errors reported by the latest eslint 2016-12-20 17:37:54 +01:00
Siddhi Pai 3baa61590e Fix block padding
* Remove test/.eslintrc
* run eslint . --fix
2016-12-13 16:05:50 -08:00
Simon Ho c5e905f5c4 Fix linter errors for CI 2016-12-09 18:13:58 -08: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š 80d2264bc9 Merge pull request #1179 from strongloop/update/eslint
Upgrade eslint & config to latest
2016-12-06 10:12:11 +01:00
Loay e14c48719e Fix MySql CI server Failure 2016-12-05 11:42:08 -05: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
jannyHou 6c8e806bc8 Apply hasManyThrough filter on target model 2016-12-01 10:08:27 -05:00
Amir Jafarian e391fd0f3e Tests cleanup
* Tests cleanup for `manipulation.test` and `scope.test`
2016-11-29 10:45:03 -05:00
Amir Jafarian fab269687b Correct tests for DAO.Create
* Create does not return data back
2016-11-28 17:18:10 -05:00
Amir Jafarian d908a52753 Fix a test
* Fix location for an instance in a test
2016-10-30 20:50:06 -04:00
Amir Jafarian 756e936c4b Add more robust OH tests for find method 2016-10-28 16:56:38 -04: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
Amir Jafarian a65311dc7c Use imperative mood for tests
* Use imperative mood for tests in test/loopback-dl.test.js
2016-10-27 16:38:40 -04:00
Heath Morrison 266e9f5a9a Continue _coerce after logical operators 2016-10-25 23:09:46 +03:00
Amir Jafarian 212e9b1f85 Make variable names more clear
* Fix up #1109
2016-10-21 17:26:39 -04:00
Amirali Jafarian d9a736a4a8 Merge pull request #1109 from C3realGuy/dev_validations
validateNumericality should skip undefined
2016-10-20 07:37:52 -04:00
Miroslav Bajtoš 011bfbb236 test/kvao: add connectorCapabilities options
- canExpire
 - canQueryTtl
 - ttlPrecision
 - canIterateKeys
 - canIterateLargeKeySets

These options allow connectors to disable shared tests for features
that are not supported/implemented.
2016-10-19 11:06:17 +02: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
Amir Jafarian f5e9b53289 Add test for operation hooks
* Add test for operation hook when near filter is used
2016-10-14 09:23:26 -04:00
Nick Duffy a23076d3a8 Add ilike and nilike operators
Closes #633
2016-10-12 18:31:31 -06:00
Loay 2cb0d042e4 Fix CI Failures in MySQL 2016-09-26 20:27:33 -04:00
Simon Ho 06d4b90071 Add code review fixups 2016-09-22 16:15:32 -07:00
Tim De Pauw 5636c15903 More descriptive name for model with shortid 2016-09-22 16:07:34 -07:00
Tim De Pauw 419a464d06 Polish PR 2016-09-22 16:07:34 -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
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
Loay 32a6b68f1d Skip test temporarily 2016-09-09 14:48:41 -04:00
Simon Ho 11ce971ad0 Fix BSON Object ID errors for CI 2016-09-08 13:16:55 -07:00
Miroslav Bajtoš a438c72cc5 Add missing "done" arg in test/kvao/ttl.suite 2016-09-08 10:22:27 +02: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 095745c93b Refactor TTL tests for KV memory connector
Reduce the complixity in the TTL test suite for the kv-memory connector
to get CI to pass.
2016-09-04 12:27:33 -07:00
Simon Ho f102f6302b Merge pull request #1075 from strongloop/forwardport/test-fix-for-expire
Fix test case for expire
2016-09-02 16:03:54 -07:00
Amirali Jafarian d888d758c0 Merge pull request #1073 from strongloop/fix_upsertWithWhere_failures
Fix failures of upsertWithWhere
2016-09-02 17:01:43 -04:00
Simon Ho b884138923 Fix test case for expire
Forwardport of #1074. #1072 was missing Promise.resolve before using
delay(20) and causing Travis to fail on 2.x. This PR makes the test code
consistent on both master and 2.x.
2016-09-02 13:59:44 -07:00
Amir Jafarian 581b8c61bf Fix failures of upsertWithWhere
Forwardport of #1052
2016-09-02 15:46:36 -04: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
Miroslav Bajtoš 6d3ea21c16 test/memory: remove dummy findOrCreate impl
Let the operation-hook tests use the real implementation,
now that we have it in place.
2016-08-26 09:46:59 +02: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
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
Sonali Samantaray 37541dd178 upsertWithWhere feature support in juggler DAO 2016-08-16 18:06:01 +05:30
Simon Ho e1a649ed58 Rename get test suite to match other test suites 2016-08-15 11:13:07 -07:00
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
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
Miroslav Bajtoš baec1b5b77 test/relation: add missing error handlers 2016-08-08 16:26:26 -04:00
jannyHou 8935b978f3 forceId=true with auto-increment db 2016-08-08 16:26:26 -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
Supasate Choochaisri f967773b2a Fix test case typo
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
2016-07-24 19:38:37 +07:00
Supasate Choochaisri 94c5c18541 Add test to catch invalid date property
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
2016-07-14 17:27:02 +07: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
Amir Jafarian 9f0c10fdff Add test for updateOrCreate
* Add test for updateOrCreate when id is not autogenerated Id
2016-07-07 12:55:22 -04:00
RobinBiondi fbe58f7cf8 give options to validators #984 2016-06-24 14:44:43 -07:00