@@ -79,7 +79,7 @@ const results = await s.getQuery('SELECT tags FROM documents WHERE slug IS_NOT_N
79
79
➜ results === [
80
80
{ tags: [' Example Tag' ] },
81
81
]
82
- const results = s .getQuery (' SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NULL ORDER BY RANDOM ASC LIMIT -1' );
82
+ const results = await s .getQuery (' SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NULL ORDER BY RANDOM ASC LIMIT -1' );
83
83
➜ results === 1
84
84
```
85
85
@@ -93,13 +93,6 @@ const results = s.getQuery('SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NUL
93
93
</dd >
94
94
</dl >
95
95
96
- ## Functions
97
-
98
- <dl >
99
- <dt ><a href =" #debug " >debug()</a > : <code >function</code ></dt >
100
- <dd ></dd >
101
- </dl >
102
-
103
96
## Typedefs
104
97
105
98
<dl >
@@ -112,7 +105,7 @@ const results = s.getQuery('SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NUL
112
105
## StorageProvider
113
106
Storage for Uttori documents using JSON files stored on the local file system.
114
107
115
- ** Kind** : global class
108
+ ** Kind** : global class
116
109
** Properties**
117
110
118
111
| Name | Type | Default | Description |
@@ -128,47 +121,50 @@ Storage for Uttori documents using JSON files stored on the local file system.
128
121
129
122
* [ StorageProvider] ( #StorageProvider )
130
123
* [ new StorageProvider(config)] ( #new_StorageProvider_new )
131
- * [ .all()] ( #StorageProvider+all ) ⇒ <code >object</code >
132
- * [ .getQuery(query)] ( #StorageProvider+getQuery ) ⇒ <code >Promise.< ; (Array.< ; UttoriDocument> ; \| number)> ; </code >
133
- * [ .get(slug)] ( #StorageProvider+get ) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
134
- * [ .add(document)] ( #StorageProvider+add )
135
- * [ .updateValid(document, originalSlug)] ( #StorageProvider+updateValid ) ℗
136
- * [ .update(params)] ( #StorageProvider+update )
137
- * [ .delete(slug)] ( #StorageProvider+delete )
138
- * [ .getHistory(slug)] ( #StorageProvider+getHistory ) ⇒ <code >Promise.< ; Array.< ; string> ;> ; </code >
139
- * [ .getRevision(params)] ( #StorageProvider+getRevision ) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
140
- * [ .updateHistory(slug, content, [ originalSlug] )] ( #StorageProvider+updateHistory )
124
+ * _ instance_
125
+ * [ .all()] ( #StorageProvider+all ) ⇒ <code >Promise.< ; object> ; </code >
126
+ * [ .getQuery(query)] ( #StorageProvider+getQuery ) ⇒ <code >Promise.< ; (Array.< ; UttoriDocument> ; \| number)> ; </code >
127
+ * [ .get(slug)] ( #StorageProvider+get ) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
128
+ * [ .add(document)] ( #StorageProvider+add )
129
+ * [ .updateValid(document, originalSlug)] ( #StorageProvider+updateValid ) ℗
130
+ * [ .update(params)] ( #StorageProvider+update )
131
+ * [ .delete(slug)] ( #StorageProvider+delete )
132
+ * [ .getHistory(slug)] ( #StorageProvider+getHistory ) ⇒ <code >Promise.< ; Array.< ; string> ;> ; </code >
133
+ * [ .getRevision(params)] ( #StorageProvider+getRevision ) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
134
+ * [ .updateHistory(slug, content, [ originalSlug] )] ( #StorageProvider+updateHistory )
135
+ * _ static_
136
+ * [ .ensureDirectory(directory)] ( #StorageProvider.ensureDirectory )
141
137
142
138
<a name =" new_StorageProvider_new " ></a >
143
139
144
140
### new StorageProvider(config)
145
141
Creates an instance of StorageProvider.
146
142
147
143
148
- | Param | Type | Default | Description |
149
- | --- | --- | --- | --- |
150
- | config | <code >object</code > | | A configuration object. |
151
- | config.contentDirectory | <code >string</code > | | The directory to store documents. |
152
- | config.historyDirectory | <code >string</code > | | The directory to store document histories. |
153
- | [ config.extension] | <code >string</code > | < code > & quot ; json & quot ; </ code > | The file extension to use for file, name of the employee. |
154
- | [ config.updateTimestamps] | <code >boolean</code > | < code >true</ code > | Should update times be marked at the time of edit. |
155
- | [ config.useHistory] | <code >boolean</code > | < code >true</ code > | Should history entries be created. |
156
- | [ config.useCache] | <code >boolean</code > | < code >true</ code > | Should we cache files in memory? |
157
- | [ config.spacesDocument] | <code >number</code > | | The spaces parameter for JSON stringifying documents. |
158
- | [ config.spacesHistory] | <code >number</code > | | The spaces parameter for JSON stringifying history. |
159
-
160
- ** Example** * (Init StorageProvider)*
144
+ | Param | Type | Description |
145
+ | --- | --- | --- |
146
+ | config | <code >object</code > | A configuration object. |
147
+ | config.contentDirectory | <code >string</code > | The directory to store documents. |
148
+ | config.historyDirectory | <code >string</code > | The directory to store document histories. |
149
+ | [ config.extension] | <code >string</code > | The file extension to use for file, name of the employee. |
150
+ | [ config.updateTimestamps] | <code >boolean</code > | Should update times be marked at the time of edit. |
151
+ | [ config.useHistory] | <code >boolean</code > | Should history entries be created. |
152
+ | [ config.useCache] | <code >boolean</code > | Should we cache files in memory? |
153
+ | [ config.spacesDocument] | <code >number</code > | The spaces parameter for JSON stringifying documents. |
154
+ | [ config.spacesHistory] | <code >number</code > | The spaces parameter for JSON stringifying history. |
155
+
156
+ ** Example** * (Init StorageProvider)*
161
157
``` js
162
158
const storageProvider = new StorageProvider ({ contentDirectory: ' content' , historyDirectory: ' history' , spacesDocument: 2 });
163
159
```
164
160
<a name =" StorageProvider+all " ></a >
165
161
166
- ### storageProvider.all() ⇒ <code >object</code >
162
+ ### storageProvider.all() ⇒ <code >Promise. & lt ; object& gt ; </code >
167
163
Returns all documents.
168
164
169
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
170
- ** Returns** : <code >object</code > - All documents.
171
- ** Example**
165
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
166
+ ** Returns** : <code >Promise. & lt ; object& gt ; </code > - All documents.
167
+ ** Example**
172
168
``` js
173
169
storageProvider .all ();
174
170
➜ { first- document : { slug: ' first-document' , ... }, ... }
@@ -178,8 +174,8 @@ storageProvider.all();
178
174
### storageProvider.getQuery(query) ⇒ <code >Promise.< ; (Array.< ; UttoriDocument> ; \| number)> ; </code >
179
175
Returns all documents matching a given query.
180
176
181
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
182
- ** Returns** : <code >Promise.< ; (Array.< ; UttoriDocument> ; \| number)> ; </code > - Promise object represents all matching documents.
177
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
178
+ ** Returns** : <code >Promise.< ; (Array.< ; UttoriDocument> ; \| number)> ; </code > - Promise object represents all matching documents.
183
179
184
180
| Param | Type | Description |
185
181
| --- | --- | --- |
@@ -190,8 +186,8 @@ Returns all documents matching a given query.
190
186
### storageProvider.get(slug) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
191
187
Returns a document for a given slug.
192
188
193
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
194
- ** Returns** : <code >Promise.< ; (UttoriDocument\| undefined)> ; </code > - Promise object represents the returned UttoriDocument.
189
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
190
+ ** Returns** : <code >Promise.< ; (UttoriDocument\| undefined)> ; </code > - Promise object represents the returned UttoriDocument.
195
191
196
192
| Param | Type | Description |
197
193
| --- | --- | --- |
@@ -202,7 +198,7 @@ Returns a document for a given slug.
202
198
### storageProvider.add(document)
203
199
Saves a document to the file system.
204
200
205
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
201
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
206
202
207
203
| Param | Type | Description |
208
204
| --- | --- | --- |
@@ -213,8 +209,8 @@ Saves a document to the file system.
213
209
### storageProvider.updateValid(document, originalSlug) ℗
214
210
Updates a document and saves to the file system.
215
211
216
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
217
- ** Access** : private
212
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
213
+ ** Access** : private
218
214
219
215
| Param | Type | Description |
220
216
| --- | --- | --- |
@@ -226,7 +222,7 @@ Updates a document and saves to the file system.
226
222
### storageProvider.update(params)
227
223
Updates a document and figures out how to save to the file system.
228
224
229
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
225
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
230
226
231
227
| Param | Type | Description |
232
228
| --- | --- | --- |
@@ -239,7 +235,7 @@ Updates a document and figures out how to save to the file system.
239
235
### storageProvider.delete(slug)
240
236
Removes a document from the file system.
241
237
242
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
238
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
243
239
244
240
| Param | Type | Description |
245
241
| --- | --- | --- |
@@ -250,8 +246,8 @@ Removes a document from the file system.
250
246
### storageProvider.getHistory(slug) ⇒ <code >Promise.< ; Array.< ; string> ;> ; </code >
251
247
Returns the history of edits for a given slug.
252
248
253
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
254
- ** Returns** : <code >Promise.< ; Array.< ; string> ;> ; </code > - Promise object represents the returned history.
249
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
250
+ ** Returns** : <code >Promise.< ; Array.< ; string> ;> ; </code > - Promise object represents the returned history.
255
251
256
252
| Param | Type | Description |
257
253
| --- | --- | --- |
@@ -262,8 +258,8 @@ Returns the history of edits for a given slug.
262
258
### storageProvider.getRevision(params) ⇒ <code >Promise.< ; (UttoriDocument\| undefined)> ; </code >
263
259
Returns a specifc revision from the history of edits for a given slug and revision timestamp.
264
260
265
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
266
- ** Returns** : <code >Promise.< ; (UttoriDocument\| undefined)> ; </code > - Promise object represents the returned revision of the document.
261
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
262
+ ** Returns** : <code >Promise.< ; (UttoriDocument\| undefined)> ; </code > - Promise object represents the returned revision of the document.
267
263
268
264
| Param | Type | Description |
269
265
| --- | --- | --- |
@@ -276,22 +272,29 @@ Returns a specifc revision from the history of edits for a given slug and revisi
276
272
### storageProvider.updateHistory(slug, content, [ originalSlug] )
277
273
Updates History for a given slug, renaming the store file and history directory as needed.
278
274
279
- ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
275
+ ** Kind** : instance method of [ <code >StorageProvider</code >] ( #StorageProvider )
280
276
281
277
| Param | Type | Description |
282
278
| --- | --- | --- |
283
279
| slug | <code >string</code > | The slug of the document to update history for. |
284
280
| content | <code >string</code > | The revision of the document to be saved. |
285
281
| [ originalSlug] | <code >string</code > | The original slug identifying the document, or the slug if it has not changed. |
286
282
287
- <a name =" debug " ></a >
283
+ <a name =" StorageProvider.ensureDirectory " ></a >
284
+
285
+ ### StorageProvider.ensureDirectory(directory)
286
+ Ensure a directory exists, and if not create it.
287
+
288
+ ** Kind** : static method of [ <code >StorageProvider</code >] ( #StorageProvider )
289
+
290
+ | Param | Type | Description |
291
+ | --- | --- | --- |
292
+ | directory | <code >string</code > | The directory to ensure exists. |
288
293
289
- ## debug() : <code >function</code >
290
- ** Kind** : global function
291
294
<a name =" UttoriDocument " ></a >
292
295
293
296
## UttoriDocument
294
- ** Kind** : global typedef
297
+ ** Kind** : global typedef
295
298
** Properties**
296
299
297
300
| Name | Type | Description |
0 commit comments