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
+148-1Lines changed: 148 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,154 @@ This now has created the following structure, either on disk or as an in memory
137
137
138
138
## API
139
139
140
-
See https://ipfs.github.io/js-ipfs-repo
140
+
### Setup
141
+
142
+
#### `new Repo(path[, options])`
143
+
144
+
Creates an IPFS Repo.
145
+
146
+
Arguments:
147
+
148
+
*`path` (string, mandatory): the path for this repo
149
+
*`options` (object, optional): may contain the following values
150
+
*`lock` (string, defaults to `"fs"` in Node.js, `"memory"` in the browser): what type of lock to use. Lock has to be acquired when opening.
151
+
*`storageBackends` (object, optional): may contain the following values, which should each be a class implementing the [datastore interface](https://github.com/ipfs/interface-datastore#readme):
152
+
*`root` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at the root (`repo.set()`, `repo.get()`)
153
+
*`blocks` (defaults to [`datastore-fs`](https://github.com/ipfs/js-datastore-fs#readme) in Node.js and [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme) in the browser). Defines the back-end type used for gets and puts of values at `repo.blocks`.
154
+
*`datastore` (defaults to [`datastore-level`](https://github.com/ipfs/js-datastore-level#readme)). Defines the back-end type used as the key-valye store used for gets and puts of values at `repo.datastore`.
155
+
156
+
```js
157
+
constrepo=newRepo('path/to/repo')
158
+
```
159
+
160
+
#### `repo.init (callback)`
161
+
162
+
Creates the necessary folder structure inside the repo.
163
+
164
+
#### `repo.open (callback)`
165
+
166
+
Locks the repo.
167
+
168
+
#### `repo.close (callback)`
169
+
170
+
Unlocks the repo.
171
+
172
+
#### `repo.exists (callback)`
173
+
174
+
Tells whether this repo exists or not. Calls back with `(err, bool)`.
175
+
176
+
### Repos
177
+
178
+
Root repo:
179
+
180
+
#### `repo.put (key, value:Buffer, callback)`
181
+
182
+
Put a value at the root of the repo.
183
+
184
+
*`key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys).
185
+
186
+
#### `repo.get (key, callback)`
187
+
188
+
Get a value at the root of the repo.
189
+
190
+
*`key` can be a buffer, a string or a [Key](https://github.com/ipfs/interface-datastore#keys).
191
+
*`callback` is a callback function `function (err, result:Buffer)`
*`block` should be of type [Block](https://github.com/ipfs/js-ipfs-block#readme).
198
+
199
+
#### `repo.blocks.putMany (blocks, callback)`
200
+
201
+
Put many blocks.
202
+
203
+
*`block` should be an array of type [Block](https://github.com/ipfs/js-ipfs-block#readme).
204
+
205
+
#### `repo.blocks.get (cid, callback)`
206
+
207
+
Get block.
208
+
209
+
*`cid` is the content id of [type CID](https://github.com/ipld/js-cid#readme).
210
+
*`callback` is a callback function `function (err, result:Buffer)`
211
+
212
+
Datastore:
213
+
214
+
#### `repo.datastore`
215
+
216
+
This is contains a full implementation of [the `interface-datastore` API](https://github.com/ipfs/interface-datastore#api).
217
+
218
+
219
+
### Utils
220
+
221
+
#### `repo.config`
222
+
223
+
Instead of using `repo.set('config')` this exposes an API that allows you to set and get a decoded config object, as well as, in a safe manner, change any of the config values individually.
0 commit comments