Commit Graph

814 Commits

Author SHA1 Message Date
Amir Jafarian a1683fca59 Auto-update by eslint --fix 2016-10-19 17:04:05 -04:00
Miroslav Bajtoš 70a1552df8 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 12:33:21 +02:00
Amirali Jafarian 8caf4c8327 Merge pull request #1108 from strongloop/fix_geo_2.x
Fix the bug when near filter is used
2016-10-13 10:39:15 -04:00
Simon Ho c3eca4025c Support {defaultFn: 'shortid'} (#1110)
- Backport of strongloop/loopback-datasource-juggler#1107 (takeover of
strongloop/loopback-datasource-juggler#1101)
- Squashed relevant commits
2016-10-12 20:58:07 -07:00
Simon Ho a9d381605e Add ilike and nilike operators (#1136)
Closes #633

Backport of #1091
2016-10-12 19:19:31 -07:00
Amir Jafarian fde4c0bfd6 Fix bug when near filter is used 2016-10-11 17:08:42 -04:00
Amir Jafarian e103b50b63 Add 'isNewInstance' for updateAttributes
* Add 'isNewInstance' to loaded hook for updateAttes
2016-09-23 14:09:44 -04:00
Loay d324696d2a Skip test temporarily 2016-09-14 22:23:24 -04:00
Miroslav Bajtoš f663917fe9 Add missing "done" arg in test/kvao/ttl.suite
Backport #1086
2016-09-08 10:39:47 +02:00
pponugo 64a9b8d506 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:20:56 +02:00
Simon Ho 95bc2e93cc 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-06 16:04:33 -07:00
Amir Jafarian 12aadd4266 Fix failures for connectors 2016-09-06 13:41:50 -04:00
Sonali Samantaray 44e1d29879 upsertWithWhere feature support in juggler DAO
Backport from #1001
2016-09-06 13:41:50 -04:00
Simon Ho cf432fceec Refactor TTL test suite 2016-09-03 11:36:28 -07:00
Miroslav Bajtoš 65c8ec41e0 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:53:19 +02:00
Amir Jafarian a1a9bac9ba Implement `notify` for find method 2016-08-23 19:00:50 -04:00
Miroslav Bajtoš ab47ecfbab kvao: implement key filter 2016-08-18 10:30:55 +02:00
Miroslav Bajtoš 24a9a96a26 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 10:30:53 +02:00
Simon Ho 5001a98135 test: Rename KVAO get test suite
[back-port of #2591]
2016-08-16 09:47:23 -07:00
Miroslav Bajtoš df4a3643eb Merge pull request #1044 from strongloop/fix/kvao-promise
test/kvao: setup global.Promise on Node v0.10 [2.x only]
2016-08-15 14:05:20 +02:00
Simon Ho 421597c998 Add TTL for KeyValue related features
Backport of strongloop/loopback-datasource-juggler#1030
2016-08-12 14:49:01 -07:00
Miroslav Bajtoš 9d0d41d660 test/kvao: setup global.Promise on Node v0.10
When running the tests on Node v0.10, setup `global.Promise`
with Bluebird implementation. That way we don't have to run
this setup in the test suite of each kv connector.
2016-08-12 16:34:26 +02:00
Miroslav Bajtoš 1750583a15 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-10 14:19:05 +02:00
Miroslav Bajtoš 8013b6acd4 kvao: return 404 when expiring unknown key 2016-08-09 10:47:12 +02:00
Miroslav Bajtoš 837f58f82d 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 14:48:04 +02:00
Amir Jafarian 5a594d4855 Fix test case typo
Backport loopback-datasource-juggler#1016
2016-07-24 09:05:33 -04:00
Amir Jafarian 6efd00698b Add test for updateOrCreate
* Add test for updateOrCreate when id is not autogenerated Id
Backport loopback-datasource-juggler#989
2016-07-23 11:25:38 -04:00
Supasate Choochaisri f1a70094fa Add test to catch invalid date property
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
See https://github.com/strongloop/loopback-datasource-juggler/pull/1000
2016-07-15 10:47:44 -07:00
Miroslav Bajtoš ebcb5a0546 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 15:25:34 +02:00
Raymond Feng 6736d72b98 Merge pull request #986 from robinbiondi/postgresConcurency
Fix #984 Give request options(ex: transactions) to validators
2016-06-24 14:42:50 -07:00
RobinBiondi 35f14c38dc give options to validators #984 2016-06-24 22:04:35 +02:00
Amir Jafarian 26718c733a 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 15:54:22 -04:00
Dimitris Halatsis af8cf19242 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();
      })
2016-06-07 17:09:34 +02:00
Miroslav Bajtoš 9bf60e0d74 fix 2016-06-03 16:29:39 -04:00
Amir-61 7aa9cb357d Merge pull request #959 from strongloop/fix_err_msg
Fix error message
2016-06-01 21:00:26 -04:00
Amir Jafarian c093648525 Fix error message
* Fix error message when PK is changed in `replaceById`
2016-06-01 16:26:41 -04:00
Amir Jafarian 05ea5467cd Add test's description 2016-06-01 16:05:56 -04:00
Dimitris Halatsis 39907c6421 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',
      },
    });

[back-port of #955]
2016-06-01 13:42:55 +02:00
Amir Jafarian 0d5cff5a0a Fix incompatibility between different connectors PR#938
* Fix incompatibility for replace methods between different connectors.
2016-05-28 09:12:30 -04:00
Simon Ho 65d6d6a508 Backport ESLint from master 2016-05-20 17:35:23 +02:00
Miroslav Bajtoš bec9142100 Implement operation hooks for EmbedsMany methods
create() triggers
 - before save
 - after save

updateById() triggers
 - before save
 - after save

destroy() triggers
 - before delete
 - after delete

The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.

Limitations:

 - `before save` & `after save` hooks don't provide `ctx.isNewInstance`
 - async validations are not supported yet
 - `persist` and `loaded` hooks are not triggered at all

 - `before delete` hook does not provide `ctx.where` property and
    it's not possible to change the outcome of `destroy()` using this
    hook. Note that regular DAO does support this.

 - updating embedded instances triggers update of the parent (owning)
   model, which is correct and expected. However, the context provided
   by `before save` and `after save` hooks on the parent model is sort of
   arbitrary and may include wrong/extra data. The same probably applies
   to the scenario when deleting embedded instances triggers update of
   the parent model.

[back-port of #911]
2016-04-28 10:15:14 +02:00
Miroslav Bajtoš f65b542dab Implement operation hooks for EmbedsOne methods
create() triggers
 - before save
 - after save

udpate() triggers
 - before save
 - after save

destroy() triggers
 - before delete
 - after delete

The implementation here is intentionally left with less features
than the regular DAO methods provide, the goal is to get a partial
(but still useful!) version released soon.

[back-port of #904]
2016-04-20 10:30:56 +02:00
Miroslav Bajtoš 289eac7565 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.

[back-port of #909]
2016-04-19 17:06:04 +02:00
Miroslav Bajtoš a5187765f6 Run `eslint --fix` with config from master 2016-04-18 16:00:04 +02:00
Amir Jafarian fd1afdf6e6 Test coverages for hashed password
* Test coverages for hashed password for replaceAttributes
* Test coverages for hashed password for updateAttribute
2016-04-15 12:58:36 -04:00
Amir Jafarian 1eeacd0255 Fix `forceId` check for `replaceByIds` PR#896 2016-04-14 17:59:30 -04:00
Miroslav Bajtoš 7d7662bfef test: extract hook-monitor helper 2016-04-13 15:15:55 +02:00
Miroslav Bajtoš 90f04181a4 test: extract uid-generator helper 2016-04-13 15:15:55 +02:00
Miroslav Bajtoš 09ad9e4711 test: extract context-test-helpers 2016-04-13 15:15:53 +02:00
Amir Jafarian 7773963b62 Define `patch` aliases
*Define `patchOrCreate` as an alias for `updateOrCreate`
*Define `PatchAttributes` as an alias for `updateAttributes`
2016-04-12 16:32:17 -04:00