Commit Graph

94 Commits

Author SHA1 Message Date
Kevin Delisle f3b849bb47 castPropertyValue: throw on malformed types 2017-07-28 12:50:51 -04:00
nVitius 3df1826730 Recursively cast props on fromDb for memory conn.
In the fromDb step, nested properties weren't being hydrated properly.
This caused an issue with the ability to search on such properties as
Dates. The properties would be hydrated as a String type, and as such,
it was impossible to properly query on them.
2017-07-12 12:51:19 -07:00
Miroslav Bajtoš f8da9783bc Back-port fixes for linter errors from master 2016-12-06 10:47:27 +01:00
Amir Jafarian e038b28e8c Fix manually 2016-10-19 17:35:26 -04:00
Amir Jafarian a1683fca59 Auto-update by eslint --fix 2016-10-19 17:04:05 -04:00
Simon Ho a9d381605e Add ilike and nilike operators (#1136)
Closes #633

Backport of #1091
2016-10-12 19:19:31 -07: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
Sonali Samantaray 44e1d29879 upsertWithWhere feature support in juggler DAO
Backport from #1001
2016-09-06 13:41:50 -04:00
Simon Ho de84a8bc7d Merge pull request #1057 from strongloop/backport/globalize-kv-mem-connector
Globalize KeyValue Memory connector
2016-08-19 12:59:31 -07: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 873cb4eab6 Globalize KeyValue Memory connector
[back-port of #1056]
2016-08-17 18:54:30 -07: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š 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
Amir Jafarian 9da0e501da Backport globalization
Backport loopback-datasource-juggler#1022,
loopback-datasource-juggler#1024,
loopback-datasource-juggler#1026
2016-08-09 21:52:11 -04: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
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š 4000b70e38 Fix eslint errors in memory connector 2016-04-18 16:00:04 +02:00
Miroslav Bajtoš a5187765f6 Run `eslint --fix` with config from master 2016-04-18 16:00:04 +02:00
Miroslav Bajtoš 093a69328c Insert copyright headers 2016-04-06 16:51:49 +02:00
Amir Jafarian ca766f1437 Implementtaion of replace
This includes:
*implementation of replaceAttributes
*implementtaion of replaceOrCreate
2016-02-04 16:05:11 -05:00
Amir Jafarian 3bc2dacb1b Implement `findOrCreate` for memory connector 2016-01-20 11:51:47 -08:00
Michael Diguet d8678a1f03 Correction of a regression introduced by commit 632898b: when querying an empty array ([]) with a 'neq' filter, there were no matching. 2015-11-23 17:09:24 +01:00
Laurent Villeneuve 632898b022 Add support for matching array values à la mongo. 2015-08-27 23:32:53 -04:00
Laurent Villeneuve 0381f6d7e7 Support embedded query in memory connector. Fix memory connector bug
Adds support for the ability to query embedsMany models from the parent.

Fix a memory connector bug that could occur when having an "or" or "and"
clause combined with another property. In that case, the and would revert
true for 'Paul McCartney'

```
{name:'John Lennon',and: [{role:'lead'}, {vip:true}]}}
```
2015-08-18 15:56:36 -04: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
Simon Ho 4cd428a726 Fix regexp error for the memory connector
- Check for undefined/null values when accessing `regexp` key
2015-07-30 08:46:50 -07:00
Simon Ho b8f1598723 Add support for regex operator 2015-07-27 15:11:53 -07:00
Bryan Clark 1066313f3f use fromDb to deserialize data after save in Memory connector
Changes the after `save` callback in the memory connector to use the
`fromDb` method to deserialize the data passed back to upsert and
updateAttributes methods.
2015-07-14 09:08:09 -07:00
Raymond Feng 93a0342099 Add an optional `options` argument to relation methods 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
Raymond Feng 137d096cfb Allow nesting properties to be queried for memory connector
See https://github.com/strongloop/loopback/issues/517
2015-03-27 16:05:12 -07:00
Miroslav Bajtoš 84d538c1ca Merge pull request #515 from strongloop/feature/isNewInstance
Add ctx.isNewInstance for "save" hooks
2015-03-20 18:33:55 +01:00
Miroslav Bajtoš 94e6d893a7 Fix updateAll callback in "transient" connector
Fix the implementation to return an object as the result,
that's the expected API since 04f35b3.
2015-03-20 08:34:58 +01:00
Simon Ho 04f35b31b4 Memory connector returns updated records count
The memory connector now includes the number of updated items in its callback
when updating records.
2015-03-19 15:40:14 -07:00
Miroslav Bajtoš ffcaa4e76e Add ctx.isNewInstance for "save" hooks
"before save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
 - true for all CREATE operations
 - false for all UPDATE operations
 - undefined for "prototype.save"

"after save" hooks provide "ctx.isNewInstance" whenever "ctx.instance"
is set. Possible values:
 - true after all CREATE operations
 - false after all UPDATE operations
 - undefined after "updateOrCreate" and "save"

Note: both "updateOrCreate" and "prototype.updateAttributes"
don't provide `ctx.instance` to "before save" hooks, therefore
`ctx.isNewInstance` it not provided either.
2015-03-19 18:05:24 +01:00
Miroslav Bajtoš d731252941 deleteAll returns number of deleted records
The number is returned as `data.ctx` to `cb(null, data)`.
2015-03-19 17:54:22 +01:00
Miroslav Bajtoš ae3dc3cec2 Merge pull request #510 from strongloop/fix/duplicate-create
Reject CREATE with a duplicate id
2015-03-19 17:37:01 +01:00
Miroslav Bajtoš 902772f1af Reject CREATE with a duplicate id
Modify the memory connector to reject requests to create a record
with a duplicate id.

Add a unit-test to verify this behaviour across all connectors.
2015-03-16 18:26:42 +01:00
Daniel B. Vasquez 9aeaa37b1c enable between filter for memory db connector 2015-03-16 11:21:04 +01:00
Raymond Feng 4afb2385a9 Fix id type issue for update
https://github.com/strongloop/loopback/issues/1058
2015-02-02 08:44:36 -08:00
Miroslav Bajtoš 1fd6eff10f Intent-based hooks for persistence
This patch introduces a new API for "intent-based" hooks. These hooks
are not tied to a particular method (e.g. "find" or "update"). Instead,
they are triggered from all methods that execute a particular "intent".

The consumer API is very simple, there is a new method
Model.observe(name, observer), where the observer is function
observer(context, callback).

Observers are inherited by child models and it is possible to register
multiple observers for the same hook.

List of hooks:

 - query
 - before save
 - after save
 - after delete
2015-01-29 08:43:52 +01:00
Dallon Feldner e7fedc2926 Fix for #369
Remember, folks, `typeof null === 'object'`.
2015-01-12 17:38:21 -06:00
Christian Vette e45407256e fix sorting of undefined values with multiple columns 2014-12-22 21:06:01 +01:00
cvette 31c7973763 code style 2014-12-22 18:54:56 +01:00
cvette a6b8ca70af fix sorting with undefined in memory connector 2014-12-22 18:45:39 +01:00
Raymond Feng 455743167a Fix the automigrate issue
See https://github.com/strongloop/loopback-example-relations-basic/issues/6
2014-10-16 12:04:16 -07:00
Fabien Franzen b136a8fce7 Full test CRUD suite for default scope 2014-10-09 18:14:04 +02:00