Commit Graph

20 Commits

Author SHA1 Message Date
Miroslav Bajtoš 481ad566d2
eslint: autofix linting errors 2018-12-07 17:13:48 +01:00
Miroslav Bajtoš 7d50f6130b
Upgrade eslint-config-loopback + fix formatting
The new version of our config enabled function-paren-newline rule,
this commit fixes the codebase to use more consistent handling
of newlines when calling functions.
2018-07-16 08:46:25 +02:00
Miroslav Bajtoš d2ee73b9d3
Update eslint + config to latest 2018-06-12 09:13:32 +02: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
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
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š 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
Miroslav Bajtoš a438c72cc5 Add missing "done" arg in test/kvao/ttl.suite 2016-09-08 10:22:27 +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 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
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 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
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š 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