json-fs-query 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/browser/jsonFsQuery.js +781 -3849
- package/browser/jsonFsQuery.min.js +1 -1
- package/dist/data/introspect/alter.js +0 -5
- package/dist/data/introspect/alter.min.js +1 -1
- package/dist/data/introspect/create.js +6 -5
- package/dist/data/introspect/create.min.js +1 -1
- package/dist/data/introspect/definitions/key.js +0 -2
- package/dist/data/introspect/definitions/key.min.js +1 -1
- package/dist/data/introspect/definitions/record.js +0 -2
- package/dist/data/introspect/definitions/record.min.js +1 -1
- package/dist/data/introspect/drop.js +0 -4
- package/dist/data/introspect/drop.min.js +1 -1
- package/dist/data/introspect/formatDatabase.js +0 -2
- package/dist/data/introspect/formatDatabase.min.js +1 -1
- package/dist/data/introspect/index.js +0 -4
- package/dist/data/introspect/index.min.js +1 -1
- package/dist/data/introspect/packDatabase.js +0 -19
- package/dist/data/introspect/packDatabase.min.js +1 -1
- package/dist/data/queries/createRecord.js +0 -2
- package/dist/data/queries/createRecord.min.js +1 -1
- package/dist/data/queries/databaseStatements.js +0 -3
- package/dist/data/queries/databaseStatements.min.js +1 -1
- package/dist/data/queries/deleteEntity.js +0 -20
- package/dist/data/queries/deleteEntity.min.js +1 -1
- package/dist/data/queries/dropRecord.js +0 -5
- package/dist/data/queries/dropRecord.min.js +1 -1
- package/dist/data/queries/groupBy.js +0 -16
- package/dist/data/queries/groupBy.min.js +1 -1
- package/dist/data/queries/insertEntity.js +6 -37
- package/dist/data/queries/insertEntity.min.js +1 -1
- package/dist/data/queries/joinEntity.js +0 -15
- package/dist/data/queries/joinEntity.min.js +1 -1
- package/dist/data/queries/parser.js +0 -2
- package/dist/data/queries/parser.min.js +1 -1
- package/dist/data/queries/selectFields.js +0 -3
- package/dist/data/queries/selectFields.min.js +1 -1
- package/dist/data/queries/showRecords.js +0 -2
- package/dist/data/queries/showRecords.min.js +1 -1
- package/dist/data/queries/updateEntity.js +0 -4
- package/dist/data/queries/updateEntity.min.js +1 -1
- package/dist/data/queries/where.js +0 -4
- package/dist/data/queries/where.min.js +1 -1
- package/dist/data/storage/databases.js +1 -2
- package/dist/data/storage/databases.min.js +1 -1
- package/dist/data/storage/listFiles.js +0 -2
- package/dist/data/storage/listFiles.min.js +1 -1
- package/dist/data/storage/readCache.js +0 -13
- package/dist/data/storage/readCache.min.js +1 -1
- package/dist/data/storage/readJson.js +2 -2
- package/dist/data/storage/readJson.min.js +1 -1
- package/dist/data/storage/storagePath.js +0 -1
- package/dist/data/storage/storagePath.min.js +1 -1
- package/dist/data/storage/writeSet.js +0 -32
- package/dist/data/storage/writeSet.min.js +1 -1
- package/dist/data/utilities/computeKeyValue.js +0 -2
- package/dist/data/utilities/computeKeyValue.min.js +1 -1
- package/dist/data/utilities/conditionEntities.js +0 -20
- package/dist/data/utilities/conditionEntities.min.js +1 -1
- package/dist/data/utilities/conditionTree.js +0 -3
- package/dist/data/utilities/conditionTree.min.js +1 -1
- package/dist/data/utilities/config.d.ts +11 -0
- package/dist/data/utilities/config.js +15 -1
- package/dist/data/utilities/config.min.js +1 -1
- package/dist/data/utilities/databaseLock.js +0 -14
- package/dist/data/utilities/databaseLock.min.js +1 -1
- package/dist/data/utilities/deregisterRecord.js +0 -2
- package/dist/data/utilities/deregisterRecord.min.js +1 -1
- package/dist/data/utilities/fieldType.js +0 -2
- package/dist/data/utilities/fieldType.min.js +1 -1
- package/dist/data/utilities/getConditionIndexedList.js +0 -20
- package/dist/data/utilities/getConditionIndexedList.min.js +1 -1
- package/dist/data/utilities/indexBuffer.js +0 -33
- package/dist/data/utilities/indexBuffer.min.js +1 -1
- package/dist/data/utilities/indexHas.js +0 -3
- package/dist/data/utilities/indexHas.min.js +1 -1
- package/dist/data/utilities/joinBases.js +0 -33
- package/dist/data/utilities/joinBases.min.js +1 -1
- package/dist/data/utilities/keyIndexFiles.js +0 -19
- package/dist/data/utilities/keyIndexFiles.min.js +1 -1
- package/dist/data/utilities/knownFields.js +0 -21
- package/dist/data/utilities/knownFields.min.js +1 -1
- package/dist/data/utilities/mergeJoin.js +0 -2
- package/dist/data/utilities/mergeJoin.min.js +1 -1
- package/dist/data/utilities/packedTable.js +0 -3
- package/dist/data/utilities/packedTable.min.js +1 -1
- package/dist/data/utilities/parsers/findConditions.js +0 -2
- package/dist/data/utilities/parsers/findConditions.min.js +1 -1
- package/dist/data/utilities/parsers/findGroupBy.js +0 -2
- package/dist/data/utilities/parsers/findGroupBy.min.js +1 -1
- package/dist/data/utilities/parsers/maskStrings.js +0 -3
- package/dist/data/utilities/parsers/maskStrings.min.js +1 -1
- package/dist/data/utilities/parsers/parseCreate.js +0 -21
- package/dist/data/utilities/parsers/parseCreate.min.js +1 -1
- package/dist/data/utilities/parsers/splitClauses.js +0 -16
- package/dist/data/utilities/parsers/splitClauses.min.js +1 -1
- package/dist/data/utilities/parsers/splitQueries.js +0 -3
- package/dist/data/utilities/parsers/splitQueries.min.js +1 -1
- package/dist/data/utilities/reconcileJoin.d.ts +12 -0
- package/dist/data/utilities/reconcileJoin.js +28 -12
- package/dist/data/utilities/reconcileJoin.min.js +1 -1
- package/dist/data/utilities/removeFromIndex.js +0 -3
- package/dist/data/utilities/removeFromIndex.min.js +1 -1
- package/dist/data/utilities/requireNode.js +0 -1
- package/dist/data/utilities/requireNode.min.js +1 -1
- package/dist/data/utilities/retrieveRecord.js +0 -1
- package/dist/data/utilities/retrieveRecord.min.js +1 -1
- package/dist/data/utilities/retrieveRecords.js +0 -16
- package/dist/data/utilities/retrieveRecords.min.js +1 -1
- package/dist/data/utilities/rowLookup.js +0 -15
- package/dist/data/utilities/rowLookup.min.js +1 -1
- package/dist/data/utilities/runQuery.js +0 -16
- package/dist/data/utilities/runQuery.min.js +1 -1
- package/dist/data/utilities/semiJoin.js +0 -19
- package/dist/data/utilities/semiJoin.min.js +1 -1
- package/dist/data/utilities/updateIndex.js +0 -2
- package/dist/data/utilities/updateIndex.min.js +1 -1
- package/dist/index.js +0 -4
- package/dist/index.min.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -137,7 +137,7 @@ that aren't nullable reject it.
|
|
|
137
137
|
|
|
138
138
|
`useDefault: true, defaultValue: …` fills in a field that is left out. `create()` checks the default against the
|
|
139
139
|
field's type (a `null` default needs `nullable: true`) and throws if it doesn't fit. Primary key fields can't be
|
|
140
|
-
nullable. Each key needs a non-empty `fields` list naming defined fields, and unknown key properties are rejected.
|
|
140
|
+
nullable, or optional unless they're `auto` (a row has to have its key: its file is named by it). Each key needs a non-empty `fields` list naming defined fields, and unknown key properties are rejected.
|
|
141
141
|
As in SQL, a `null` is never a duplicate in a unique key (any number of rows can hold it), and
|
|
142
142
|
a `null` foreign key isn't checked against the record it references.
|
|
143
143
|
|
|
@@ -457,7 +457,7 @@ A field is `<name> <type>`, then any of these, in any order:
|
|
|
457
457
|
|---|---|
|
|
458
458
|
| `optional` | may be left out (see "Fields" above) |
|
|
459
459
|
| `null` / `not null` | may hold `null` / may not (the default) |
|
|
460
|
-
| `auto` | a UUID is generated on insert; the type must be `string` |
|
|
460
|
+
| `auto` | a UUID is generated on insert for a row that leaves the field out (or gives `null`); a value given for it is kept, as MySQL keeps an explicit `AUTO_INCREMENT` value, and still has to be unique when the field is a key. The type must be `string` |
|
|
461
461
|
| `default <value>` | used when the field is left out: a string, a number, an array, `null`, `true` or `false` (so an `object` field can only default to `null` here; `create()` takes any default) |
|
|
462
462
|
|
|
463
463
|
The types are `string`, `int`, `boolean`, `object` and `array`; any other is an error.
|
|
@@ -591,6 +591,12 @@ Queries that worked in 2.x can be errors now (each error names the problem), and
|
|
|
591
591
|
can't be read`), as `drop` and `describe` already said, instead of `Could not read <name>.json`. A join written
|
|
592
592
|
without the record to join (`read workouts on ...`) says so, instead of `Could not read .json`.
|
|
593
593
|
|
|
594
|
+
### Upgrading from 3.3
|
|
595
|
+
|
|
596
|
+
- An `auto` field keeps a value given for it on insert. Before 3.3.1, `insert foo values _id = 'mine', ...` stored the row
|
|
597
|
+
under a new UUID without a word, so copying rows with their ids (or migrating data whose other records point at those
|
|
598
|
+
ids) lost them. A row that leaves the field out, or gives `null`, still gets a new UUID.
|
|
599
|
+
|
|
594
600
|
## Configuration
|
|
595
601
|
|
|
596
602
|
`configure()` sets where this package's data lives and how strictly it enforces foreign keys - call it once,
|
|
@@ -607,7 +613,8 @@ configure({
|
|
|
607
613
|
format: 'compact', // how files are written: 'compact' or 'pretty' (default 'compact')
|
|
608
614
|
packedReads: undefined, // use packed files (see packDatabase); default true in a browser, false in Node
|
|
609
615
|
databasesPath: undefined, // a folder holding several databases (see Several databases)
|
|
610
|
-
database: undefined
|
|
616
|
+
database: undefined, // the one of them in use
|
|
617
|
+
fetchOptions: undefined // passed to every fetch() in a browser, such as { cache: 'no-cache' }
|
|
611
618
|
})
|
|
612
619
|
```
|
|
613
620
|
|
|
@@ -618,6 +625,11 @@ Reads fetch several entry files at once, `readConcurrency` at a time, and keep t
|
|
|
618
625
|
file is one request: 16 suits HTTP/2 static hosts (such as GitHub Pages), while over HTTP/1.1 a browser only opens about
|
|
619
626
|
6 connections per host anyway. `readConcurrency: 1` reads one file at a time, as every read did before this setting.
|
|
620
627
|
|
|
628
|
+
`fetchOptions` is given to every `fetch()` a browser read makes, as its second argument. By default reads use the
|
|
629
|
+
browser's normal HTTP cache, which suits data that only changes when the site is deployed. When something writes the
|
|
630
|
+
files while the page is in use (a local server, say), `{ cache: 'no-cache' }` makes the browser check every file with the
|
|
631
|
+
server before using its cached copy: an unchanged file comes back as a short "not modified", a changed one is read again.
|
|
632
|
+
|
|
621
633
|
### Several databases: `databasesPath`, `use`
|
|
622
634
|
|
|
623
635
|
One program can keep several databases (say, real data and a test copy) in one folder and switch between them:
|