You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-45Lines changed: 60 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,5 @@
1
1
# feathers-nedb
2
2
3
-
> :warning:**DEPRECATED**: Not compatible with Feathers v5. Please use [another adapter instead](https://www.npmjs.com/search?ranking=optimal&q=FeathersJS%20database%20adapter).
[feathers-nedb](https://github.com/feathersjs-ecosystem/feathers-nedb/) is a database service adapter for [NeDB](https://github.com/seald/nedb), an embedded datastore with a [MongoDB](https://www.mongodb.org/) like API. NeDB can store data in-memory or on the filesystem which makes it useful as a persistent storage without a separate database server.
@@ -10,7 +8,7 @@
10
8
$ npm install --save @seald-io/nedb feathers-nedb
11
9
```
12
10
13
-
> __Important:__`feathers-nedb` implements the [Feathers Common database adapter API](https://docs.feathersjs.com/api/databases/common.html) and [querying syntax](https://docs.feathersjs.com/api/databases/querying.html).
11
+
> **Important:**`feathers-nedb` implements the [Feathers Common database adapter API](https://docs.feathersjs.com/api/databases/common.html) and [querying syntax](https://docs.feathersjs.com/api/databases/querying.html).
-`Model` (**required**) - The NeDB database instance. See the [NeDB API](https://github.com/seald/nedb#documentation) for more information.
38
-
-`id` (*optional*, default: `'_id'`) - The name of the id field property. By design, NeDB will always add an `_id` property.
39
-
-`events` (*optional*) - A list of [custom service events](https://docs.feathersjs.com/api/events.html#custom-events) sent by this service
40
-
-`paginate` (*optional*) - A [pagination object](https://docs.feathersjs.com/api/databases/common.html#pagination) containing a `default` and `max` page size
41
-
-`whitelist` (*optional*) - A list of additional query parameters to allow (e.g. `[ '$regex' ]`)
42
-
-`multi` (*optional*) - Allow `create` with arrays and `update` and `remove` with `id` null to change multiple items. Can be `true` for all methods or an array of multi methods (e.g. `[ 'remove', 'create' ]`)
36
+
-`id` (_optional_, default: `'_id'`) - The name of the id field property. By design, NeDB will always add an `_id` property.
37
+
-`events` (_optional_) - A list of [custom service events](https://docs.feathersjs.com/api/events.html#custom-events) sent by this service
38
+
-`paginate` (_optional_) - A [pagination object](https://docs.feathersjs.com/api/databases/common.html#pagination) containing a `default` and `max` page size
39
+
-`whitelist` (_optional_) - A list of additional query parameters to allow (e.g. `[ '$regex' ]`)
40
+
-`multi` (_optional_) - Allow `create` with arrays and `update` and `remove` with `id` null to change multiple items. Can be `true` for all methods or an array of multi methods (e.g. `[ 'remove', 'create' ]`)
43
41
44
42
### params.nedb
45
43
46
44
When making a [service method](https://docs.feathersjs.com/api/services.html) call, `params` can contain an `nedb` property which allows to pass additional [NeDB options](https://github.com/seald/nedb#updating-documents), for example to allow `upsert`:
47
45
48
46
```js
49
-
app.service('messages').update('someid', {
50
-
text:'This message will be either created or updated'
51
-
}, {
52
-
nedb: { upsert:true }
53
-
});
47
+
app.service("messages").update(
48
+
"someid",
49
+
{
50
+
text:"This message will be either created or updated",
51
+
},
52
+
{
53
+
nedb: { upsert:true },
54
+
}
55
+
);
54
56
```
55
57
56
58
### use of params on client
59
+
57
60
On client you can't pass anything other than a query as the parameter. So you need to do it like this.
58
61
59
62
```js
60
63
// client side
61
-
app.service('messages').update('someid', {
62
-
text:'This message will be either created or updated'
63
-
}, {
64
-
query: {nedb: { upsert:true }}
65
-
});
64
+
app.service("messages").update(
65
+
"someid",
66
+
{
67
+
text:"This message will be either created or updated",
68
+
},
69
+
{
70
+
query: { nedb: { upsert:true } },
71
+
}
72
+
);
66
73
```
74
+
67
75
then add a hook to the service to move the nedb options to the params object
0 commit comments