Skip to content

Commit e390361

Browse files
committed
Update README
1 parent 55aedb3 commit e390361

File tree

6 files changed

+115
-142
lines changed

6 files changed

+115
-142
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## [5.0.0](https://github.com/uttori/uttori-storage-provider-json-file/compare/v4.2.1...v5.0.0) - 2023-12-14
5+
## [5.0.0](https://github.com/uttori/uttori-storage-provider-json-file/compare/v4.2.1...v5.0.0) - 2023-12-16
66

77
- 💥 BREAKING CHANGES!
88
- 💥 Rename config key: `content_directory` to `contentDirectory`

README.md

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const results = await s.getQuery('SELECT tags FROM documents WHERE slug IS_NOT_N
7979
➜ results === [
8080
{ tags: ['Example Tag'] },
8181
]
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');
8383
➜ results === 1
8484
```
8585

@@ -93,13 +93,6 @@ const results = s.getQuery('SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NUL
9393
</dd>
9494
</dl>
9595

96-
## Functions
97-
98-
<dl>
99-
<dt><a href="#debug">debug()</a> : <code>function</code></dt>
100-
<dd></dd>
101-
</dl>
102-
10396
## Typedefs
10497

10598
<dl>
@@ -112,7 +105,7 @@ const results = s.getQuery('SELECT COUNT(*) FROM documents WHERE slug IS_NOT_NUL
112105
## StorageProvider
113106
Storage for Uttori documents using JSON files stored on the local file system.
114107

115-
**Kind**: global class
108+
**Kind**: global class
116109
**Properties**
117110

118111
| Name | Type | Default | Description |
@@ -128,47 +121,50 @@ Storage for Uttori documents using JSON files stored on the local file system.
128121

129122
* [StorageProvider](#StorageProvider)
130123
* [new StorageProvider(config)](#new_StorageProvider_new)
131-
* [.all()](#StorageProvider+all) ⇒ <code>object</code>
132-
* [.getQuery(query)](#StorageProvider+getQuery) ⇒ <code>Promise.&lt;(Array.&lt;UttoriDocument&gt;\|number)&gt;</code>
133-
* [.get(slug)](#StorageProvider+get) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</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.&lt;Array.&lt;string&gt;&gt;</code>
139-
* [.getRevision(params)](#StorageProvider+getRevision) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code>
140-
* [.updateHistory(slug, content, [originalSlug])](#StorageProvider+updateHistory)
124+
* _instance_
125+
* [.all()](#StorageProvider+all) ⇒ <code>Promise.&lt;object&gt;</code>
126+
* [.getQuery(query)](#StorageProvider+getQuery) ⇒ <code>Promise.&lt;(Array.&lt;UttoriDocument&gt;\|number)&gt;</code>
127+
* [.get(slug)](#StorageProvider+get) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</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.&lt;Array.&lt;string&gt;&gt;</code>
133+
* [.getRevision(params)](#StorageProvider+getRevision) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code>
134+
* [.updateHistory(slug, content, [originalSlug])](#StorageProvider+updateHistory)
135+
* _static_
136+
* [.ensureDirectory(directory)](#StorageProvider.ensureDirectory)
141137

142138
<a name="new_StorageProvider_new"></a>
143139

144140
### new StorageProvider(config)
145141
Creates an instance of StorageProvider.
146142

147143

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)*
161157
```js
162158
const storageProvider = new StorageProvider({ contentDirectory: 'content', historyDirectory: 'history', spacesDocument: 2 });
163159
```
164160
<a name="StorageProvider+all"></a>
165161

166-
### storageProvider.all() ⇒ <code>object</code>
162+
### storageProvider.all() ⇒ <code>Promise.&lt;object&gt;</code>
167163
Returns all documents.
168164

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**
172168
```js
173169
storageProvider.all();
174170
➜ { first-document: { slug: 'first-document', ... }, ...}
@@ -178,8 +174,8 @@ storageProvider.all();
178174
### storageProvider.getQuery(query) ⇒ <code>Promise.&lt;(Array.&lt;UttoriDocument&gt;\|number)&gt;</code>
179175
Returns all documents matching a given query.
180176

181-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
182-
**Returns**: <code>Promise.&lt;(Array.&lt;UttoriDocument&gt;\|number)&gt;</code> - Promise object represents all matching documents.
177+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
178+
**Returns**: <code>Promise.&lt;(Array.&lt;UttoriDocument&gt;\|number)&gt;</code> - Promise object represents all matching documents.
183179

184180
| Param | Type | Description |
185181
| --- | --- | --- |
@@ -190,8 +186,8 @@ Returns all documents matching a given query.
190186
### storageProvider.get(slug) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code>
191187
Returns a document for a given slug.
192188

193-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
194-
**Returns**: <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code> - Promise object represents the returned UttoriDocument.
189+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
190+
**Returns**: <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code> - Promise object represents the returned UttoriDocument.
195191

196192
| Param | Type | Description |
197193
| --- | --- | --- |
@@ -202,7 +198,7 @@ Returns a document for a given slug.
202198
### storageProvider.add(document)
203199
Saves a document to the file system.
204200

205-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
201+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
206202

207203
| Param | Type | Description |
208204
| --- | --- | --- |
@@ -213,8 +209,8 @@ Saves a document to the file system.
213209
### storageProvider.updateValid(document, originalSlug) ℗
214210
Updates a document and saves to the file system.
215211

216-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
217-
**Access**: private
212+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
213+
**Access**: private
218214

219215
| Param | Type | Description |
220216
| --- | --- | --- |
@@ -226,7 +222,7 @@ Updates a document and saves to the file system.
226222
### storageProvider.update(params)
227223
Updates a document and figures out how to save to the file system.
228224

229-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
225+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
230226

231227
| Param | Type | Description |
232228
| --- | --- | --- |
@@ -239,7 +235,7 @@ Updates a document and figures out how to save to the file system.
239235
### storageProvider.delete(slug)
240236
Removes a document from the file system.
241237

242-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
238+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
243239

244240
| Param | Type | Description |
245241
| --- | --- | --- |
@@ -250,8 +246,8 @@ Removes a document from the file system.
250246
### storageProvider.getHistory(slug) ⇒ <code>Promise.&lt;Array.&lt;string&gt;&gt;</code>
251247
Returns the history of edits for a given slug.
252248

253-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
254-
**Returns**: <code>Promise.&lt;Array.&lt;string&gt;&gt;</code> - Promise object represents the returned history.
249+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
250+
**Returns**: <code>Promise.&lt;Array.&lt;string&gt;&gt;</code> - Promise object represents the returned history.
255251

256252
| Param | Type | Description |
257253
| --- | --- | --- |
@@ -262,8 +258,8 @@ Returns the history of edits for a given slug.
262258
### storageProvider.getRevision(params) ⇒ <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code>
263259
Returns a specifc revision from the history of edits for a given slug and revision timestamp.
264260

265-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
266-
**Returns**: <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code> - Promise object represents the returned revision of the document.
261+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
262+
**Returns**: <code>Promise.&lt;(UttoriDocument\|undefined)&gt;</code> - Promise object represents the returned revision of the document.
267263

268264
| Param | Type | Description |
269265
| --- | --- | --- |
@@ -276,22 +272,29 @@ Returns a specifc revision from the history of edits for a given slug and revisi
276272
### storageProvider.updateHistory(slug, content, [originalSlug])
277273
Updates History for a given slug, renaming the store file and history directory as needed.
278274

279-
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
275+
**Kind**: instance method of [<code>StorageProvider</code>](#StorageProvider)
280276

281277
| Param | Type | Description |
282278
| --- | --- | --- |
283279
| slug | <code>string</code> | The slug of the document to update history for. |
284280
| content | <code>string</code> | The revision of the document to be saved. |
285281
| [originalSlug] | <code>string</code> | The original slug identifying the document, or the slug if it has not changed. |
286282

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. |
288293

289-
## debug() : <code>function</code>
290-
**Kind**: global function
291294
<a name="UttoriDocument"></a>
292295

293296
## UttoriDocument
294-
**Kind**: global typedef
297+
**Kind**: global typedef
295298
**Properties**
296299

297300
| Name | Type | Description |

docs/plugin.md

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
## Classes
2-
3-
<dl>
4-
<dt><a href="#Plugin">Plugin</a></dt>
5-
<dd><p>Uttori Storage Provider - JSON File</p>
6-
</dd>
7-
</dl>
8-
9-
## Functions
10-
11-
<dl>
12-
<dt><a href="#debug">debug()</a> : <code>function</code></dt>
13-
<dd></dd>
14-
</dl>
15-
161
<a name="Plugin"></a>
172

183
## Plugin
@@ -86,7 +71,3 @@ const context = {
8671
};
8772
Plugin.register(context);
8873
```
89-
<a name="debug"></a>
90-
91-
## debug() : <code>function</code>
92-
**Kind**: global function

docs/query-tools.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
## Functions
2-
3-
<dl>
4-
<dt><a href="#debug">debug()</a> : <code>function</code></dt>
5-
<dd></dd>
6-
<dt><a href="#processQuery">processQuery(query, objects)</a> ⇒ <code>Array.&lt;object&gt;</code> | <code>number</code></dt>
7-
<dd><p>Processes a query string.</p>
8-
</dd>
9-
</dl>
10-
11-
<a name="debug"></a>
12-
13-
## debug() : <code>function</code>
14-
**Kind**: global function
151
<a name="processQuery"></a>
162

173
## processQuery(query, objects) ⇒ <code>Array.&lt;object&gt;</code> \| <code>number</code>

0 commit comments

Comments
 (0)