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
+24-28Lines changed: 24 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,20 +77,10 @@ var levelup = require("levelup"),
77
77
db =jsonld(levelgraph(yourDB), opts);
78
78
```
79
79
80
-
By default `update`s (and `delete`s) **delete all triples associated to the `@id` of the document before updating it**, the `'preserve'` option will ensure that all `put`s and `delete`s only update the triples that are mentioned in the document:
81
-
82
-
83
-
```javascript
84
-
var levelup =require("levelup"),
85
-
yourDB =levelup("./yourdb"),
86
-
levelgraph =require('levelgraph'),
87
-
jsonld =require('levelgraph-jsonld'),
88
-
opts = {
89
-
base:'http://matteocollina.com/base',
90
-
preserve:true
91
-
},
92
-
db =jsonld(levelgraph(yourDB), opts);
93
-
```
80
+
> From v1, overwriting and deleting is more conservative. If you rely on the previous behavior you can set the `overwrite` option to `true` (when creating the db or as options to `put` and `del`) to:
81
+
> - overwrite all existing triples when using `put`
82
+
> - delete all blank nodes recursively when using `del` (cf upcoming `cut` function)
By default, `put`**deletes all triples associated to the `@id` of the document before updating it**. If you want to instead only update the triples that are part of the document you can use the `{ preserve : true }` option (you can also [set it globally when you create the DB](#usage)):
In order to delete an object, you can just pass it's `'@id'` to the
216
-
`'@del'` method:
197
+
In order to delete an object, you need to pass the document to the `'del'` method which will delete only the properties specified in the document:
217
198
```javascript
218
-
db.jsonld.del(manu['@id'], function(err) {
199
+
db.jsonld.del(manu, function(err) {
219
200
// do something after it is deleted!
220
201
});
221
202
```
222
203
223
-
By default, `del`**deletes all triples associated to the `@id`**. If you want to instead only delete the triples that are part of the document, you can use the `{ preserve : true }` option (you can also [set it globally when you create the DB](#usage)):
204
+
Note that blank nodes are ignored, so to delete blank nodes you need to pass the `cut: true` option (you can also add the `recurse: true`option) or use the `'cut'` method below.
224
205
206
+
> Note that since v1 `'del'` doesn't support passing an IRI anymore.
207
+
208
+
### Cut
209
+
210
+
In order to delete the blank nodes object, you can just pass it's `'@id'` to the
You can also pass an object, but in this case the properties are not used to determine which triples will be deleted and only the `@id`s are considered.
219
+
220
+
Using the `recurse` option you can follow all links and blank nodes (which might result in deleting more data than you expect)
0 commit comments