json-fs-query 0.1.0 → 1.0.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 +41 -6
- package/browser/jsonFsQuery.js +28271 -0
- package/browser/jsonFsQuery.min.js +1 -0
- package/dist/data/introspect/create.js +6 -4
- package/dist/data/introspect/create.min.js +1 -1
- package/dist/data/introspect/drop.js +2 -2
- package/dist/data/introspect/drop.min.js +1 -1
- package/dist/data/introspect/policies/hasDependents.d.ts +13 -0
- package/dist/data/introspect/policies/hasDependents.js +52 -0
- package/dist/data/introspect/policies/hasDependents.min.js +1 -0
- package/dist/data/introspect/policies/keyGenerate.js +1 -1
- package/dist/data/introspect/policies/keyGenerate.min.js +1 -1
- package/dist/data/introspect/policies/keyUnique.d.ts +9 -1
- package/dist/data/introspect/policies/keyUnique.js +19 -9
- package/dist/data/introspect/policies/keyUnique.min.js +1 -1
- package/dist/data/queries/deleteEntity.js +36 -15
- package/dist/data/queries/deleteEntity.min.js +1 -1
- package/dist/data/queries/groupBy.js +22 -22
- package/dist/data/queries/groupBy.min.js +1 -1
- package/dist/data/queries/insertEntity.js +14 -12
- package/dist/data/queries/insertEntity.min.js +1 -1
- package/dist/data/queries/readEntity.js +1 -1
- package/dist/data/queries/readEntity.min.js +1 -1
- package/dist/data/queries/updateEntity.js +68 -42
- package/dist/data/queries/updateEntity.min.js +1 -1
- package/dist/data/queries/where.js +1 -1
- package/dist/data/queries/where.min.js +1 -1
- package/dist/data/utilities/computeKeyValue.d.ts +13 -0
- package/dist/data/utilities/computeKeyValue.js +26 -0
- package/dist/data/utilities/computeKeyValue.min.js +1 -0
- package/dist/data/utilities/config.d.ts +28 -0
- package/dist/data/utilities/config.js +45 -0
- package/dist/data/utilities/config.min.js +1 -0
- package/dist/data/utilities/deregisterRecord.js +2 -2
- package/dist/data/utilities/deregisterRecord.min.js +1 -1
- package/dist/data/utilities/getConditionIndexedList.js +1 -1
- package/dist/data/utilities/getConditionIndexedList.min.js +1 -1
- package/dist/data/utilities/getJoinIndexedList.js +2 -2
- package/dist/data/utilities/getJoinIndexedList.min.js +1 -1
- package/dist/data/utilities/getMatchingIndexes.js +2 -2
- package/dist/data/utilities/getMatchingIndexes.min.js +1 -1
- package/dist/data/utilities/matchIndexedJoins.js +2 -2
- package/dist/data/utilities/matchIndexedJoins.min.js +1 -1
- package/dist/data/utilities/reconcileJoin.js +26 -26
- package/dist/data/utilities/reconcileJoin.min.js +1 -1
- package/dist/data/utilities/reconcileJoins.js +26 -27
- package/dist/data/utilities/reconcileJoins.min.js +1 -1
- package/dist/data/utilities/registerRecord.js +2 -2
- package/dist/data/utilities/registerRecord.min.js +1 -1
- package/dist/data/utilities/removeFromIndex.js +2 -2
- package/dist/data/utilities/removeFromIndex.min.js +1 -1
- package/dist/data/utilities/restrictIndexedList.js +45 -45
- package/dist/data/utilities/restrictIndexedList.min.js +1 -1
- package/dist/data/utilities/retrieveFile.js +3 -3
- package/dist/data/utilities/retrieveFile.min.js +1 -1
- package/dist/data/utilities/retrieveIndexes.js +1 -1
- package/dist/data/utilities/retrieveIndexes.min.js +1 -1
- package/dist/data/utilities/updateIndex.js +2 -2
- package/dist/data/utilities/updateIndex.min.js +1 -1
- package/dist/data/utilities/useJoinClause.js +4 -4
- package/dist/data/utilities/useJoinClause.min.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +7 -0
- package/dist/index.min.js +1 -1
- package/package.json +11 -4
- package/.browserslistrc +0 -1
- package/.nvmrc +0 -1
- package/MAIN.md +0 -15
- package/babel.config.js +0 -3
- package/build-tools.config.json +0 -30
- package/gulpfile.mjs +0 -15
- package/src/data/introspect/create.test.js +0 -67
- package/src/data/introspect/create.ts +0 -29
- package/src/data/introspect/definitions/field.test.js +0 -23
- package/src/data/introspect/definitions/field.ts +0 -48
- package/src/data/introspect/definitions/key.test.js +0 -100
- package/src/data/introspect/definitions/key.ts +0 -64
- package/src/data/introspect/definitions/keyReference.test.js +0 -8
- package/src/data/introspect/definitions/keyReference.ts +0 -23
- package/src/data/introspect/definitions/record.ts +0 -42
- package/src/data/introspect/describe.test.js +0 -36
- package/src/data/introspect/describe.ts +0 -9
- package/src/data/introspect/drop.test.js +0 -77
- package/src/data/introspect/drop.ts +0 -20
- package/src/data/introspect/index.ts +0 -8
- package/src/data/introspect/policies/foreignKeyExists.test.js +0 -44
- package/src/data/introspect/policies/foreignKeyExists.ts +0 -15
- package/src/data/introspect/policies/keyGenerate.ts +0 -11
- package/src/data/introspect/policies/keyUnique.ts +0 -11
- package/src/data/introspect/policies/typeCheck.test.js +0 -84
- package/src/data/introspect/policies/typeCheck.ts +0 -49
- package/src/data/introspect/policies/typeEnum.ts +0 -6
- package/src/data/introspect/policies/useDefault.ts +0 -6
- package/src/data/queries/deleteEntity.test.js +0 -86
- package/src/data/queries/deleteEntity.ts +0 -56
- package/src/data/queries/groupBy.test.js +0 -135
- package/src/data/queries/groupBy.ts +0 -16
- package/src/data/queries/insertEntity.test.js +0 -156
- package/src/data/queries/insertEntity.ts +0 -113
- package/src/data/queries/joinEntity.test.js +0 -109
- package/src/data/queries/joinEntity.ts +0 -20
- package/src/data/queries/mergeJoins.test.js +0 -174
- package/src/data/queries/mergeJoins.ts +0 -13
- package/src/data/queries/parser.test.js +0 -343
- package/src/data/queries/parser.ts +0 -24
- package/src/data/queries/query.test.js +0 -233
- package/src/data/queries/query.ts +0 -12
- package/src/data/queries/readEntity.test.js +0 -85
- package/src/data/queries/readEntity.ts +0 -8
- package/src/data/queries/sortBy.test.js +0 -131
- package/src/data/queries/sortBy.ts +0 -18
- package/src/data/queries/updateEntity.test.js +0 -228
- package/src/data/queries/updateEntity.ts +0 -162
- package/src/data/queries/where.test.js +0 -129
- package/src/data/queries/where.ts +0 -54
- package/src/data/utilities/deregisterRecord.test.js +0 -26
- package/src/data/utilities/deregisterRecord.ts +0 -24
- package/src/data/utilities/getConditionIndexedList.ts +0 -43
- package/src/data/utilities/getJoinIndexedList.ts +0 -53
- package/src/data/utilities/getMatchingIndexes.ts +0 -21
- package/src/data/utilities/matchIndexedJoins.ts +0 -45
- package/src/data/utilities/mergeJoin.test.js +0 -102
- package/src/data/utilities/mergeJoin.ts +0 -28
- package/src/data/utilities/parsers/findCommand.ts +0 -25
- package/src/data/utilities/parsers/findConditions.test.js +0 -38
- package/src/data/utilities/parsers/findConditions.ts +0 -32
- package/src/data/utilities/parsers/findGroupBy.ts +0 -20
- package/src/data/utilities/parsers/findInsertValues.test.js +0 -26
- package/src/data/utilities/parsers/findInsertValues.ts +0 -32
- package/src/data/utilities/parsers/findJoinClauses.ts +0 -29
- package/src/data/utilities/parsers/findJoinEntity.ts +0 -20
- package/src/data/utilities/parsers/findLimit.ts +0 -20
- package/src/data/utilities/parsers/findMergeJoins.ts +0 -27
- package/src/data/utilities/parsers/findOffset.ts +0 -20
- package/src/data/utilities/parsers/findSelects.ts +0 -31
- package/src/data/utilities/parsers/findSortClauses.ts +0 -31
- package/src/data/utilities/parsers/findUpdateValues.test.js +0 -37
- package/src/data/utilities/parsers/findUpdateValues.ts +0 -32
- package/src/data/utilities/parsers/isEntityProperty.ts +0 -1
- package/src/data/utilities/parsers/parseLiteralValue.test.js +0 -41
- package/src/data/utilities/parsers/parseLiteralValue.ts +0 -29
- package/src/data/utilities/parsers/parseQuery.ts +0 -73
- package/src/data/utilities/parsers/removeFromQuery.ts +0 -1
- package/src/data/utilities/parsers/splitEntityProperty.test.js +0 -8
- package/src/data/utilities/parsers/splitEntityProperty.ts +0 -17
- package/src/data/utilities/parsers/splitQueries.test.js +0 -33
- package/src/data/utilities/parsers/splitQueries.ts +0 -4
- package/src/data/utilities/reconcileJoin.test.js +0 -38
- package/src/data/utilities/reconcileJoin.ts +0 -23
- package/src/data/utilities/reconcileJoins.test.js +0 -160
- package/src/data/utilities/reconcileJoins.ts +0 -15
- package/src/data/utilities/registerRecord.test.js +0 -44
- package/src/data/utilities/registerRecord.ts +0 -44
- package/src/data/utilities/removeFromIndex.test.js +0 -44
- package/src/data/utilities/removeFromIndex.ts +0 -34
- package/src/data/utilities/restrictIndexedList.ts +0 -38
- package/src/data/utilities/retrieveFile.test.js +0 -49
- package/src/data/utilities/retrieveFile.ts +0 -19
- package/src/data/utilities/retrieveIndexes.ts +0 -17
- package/src/data/utilities/retrieveRecord.ts +0 -3
- package/src/data/utilities/retrieveRecords.test.js +0 -223
- package/src/data/utilities/retrieveRecords.ts +0 -16
- package/src/data/utilities/runQuery.test.js +0 -88
- package/src/data/utilities/runQuery.ts +0 -75
- package/src/data/utilities/updateIndex.test.js +0 -44
- package/src/data/utilities/updateIndex.ts +0 -45
- package/src/data/utilities/useJoinClause.test.js +0 -94
- package/src/data/utilities/useJoinClause.ts +0 -44
- package/src/global.d.ts +0 -1
- package/src/index.test.js +0 -52
- package/src/index.ts +0 -17
- package/test-data/__RECORDS.json +0 -32
- package/test-data/__indexes/exercise_muscle/fk_exercise_id.json +0 -14
- package/test-data/__indexes/exercise_muscle/fk_muscle_id.json +0 -14
- package/test-data/__indexes/exercise_muscle/pk__id.json +0 -14
- package/test-data/__indexes/exercises/pk__id.json +0 -14
- package/test-data/__indexes/muscles/pk__id.json +0 -58
- package/test-data/__indexes/workouts/fk_exercise_id.json +0 -23
- package/test-data/__indexes/workouts/index_date.json +0 -18
- package/test-data/__indexes/workouts/pk__id.json +0 -26
- package/test-data/copyDatabase.ts +0 -64
- package/test-data/exercise_muscle/bench_press_pectorals.json +0 -6
- package/test-data/exercise_muscle/deadlift_hamstrings.json +0 -6
- package/test-data/exercise_muscle/squat_quadriceps.json +0 -6
- package/test-data/exercise_muscle.json +0 -69
- package/test-data/exercises/bench_press.json +0 -5
- package/test-data/exercises/deadlift.json +0 -5
- package/test-data/exercises/squat.json +0 -5
- package/test-data/exercises.json +0 -34
- package/test-data/muscles/abdominal.json +0 -6
- package/test-data/muscles/biceps.json +0 -6
- package/test-data/muscles/calves.json +0 -6
- package/test-data/muscles/deltoids.json +0 -6
- package/test-data/muscles/erector_spinae.json +0 -6
- package/test-data/muscles/forearms.json +0 -6
- package/test-data/muscles/gluteus_maximus.json +0 -6
- package/test-data/muscles/hamstrings.json +0 -6
- package/test-data/muscles/latissimus_dorsi.json +0 -6
- package/test-data/muscles/obliques.json +0 -6
- package/test-data/muscles/pectorals.json +0 -6
- package/test-data/muscles/quadriceps.json +0 -6
- package/test-data/muscles/trapezius.json +0 -6
- package/test-data/muscles/triceps.json +0 -6
- package/test-data/muscles.json +0 -50
- package/test-data/workouts/2024-06-02-001.json +0 -10
- package/test-data/workouts/2024-06-02-002.json +0 -10
- package/test-data/workouts/2024-06-02-003.json +0 -10
- package/test-data/workouts/2024-06-05-001.json +0 -10
- package/test-data/workouts/2024-06-05-002.json +0 -10
- package/test-data/workouts/2024-06-05-003.json +0 -10
- package/test-data/workouts.json +0 -84
- package/tsconfig.json +0 -15
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useJoinClause } from './useJoinClause'
|
|
2
|
-
import { testHelpers } from 'js-build-tools/testHelpers'
|
|
3
|
-
import { copyDatabase } from '../../../test-data/copyDatabase'
|
|
4
|
-
|
|
5
|
-
const databasePath = 'use-join-clause-database/'
|
|
6
|
-
const gulpConfig = testHelpers.gulpConfig
|
|
7
|
-
gulpConfig.set('databasePath', databasePath)
|
|
8
|
-
testHelpers.setDefaults(databasePath)
|
|
9
|
-
|
|
10
|
-
beforeEach(
|
|
11
|
-
() => testHelpers.beforeEach()
|
|
12
|
-
.then(() => copyDatabase(databasePath))
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
afterEach(testHelpers.afterEach)
|
|
16
|
-
|
|
17
|
-
describe('useJoinClause', () => {
|
|
18
|
-
test('it will find the joins', async () => {
|
|
19
|
-
const result = await useJoinClause({
|
|
20
|
-
propertyA: 'workouts.exercise_id',
|
|
21
|
-
comparator: '=',
|
|
22
|
-
propertyB: 'exercises._id'
|
|
23
|
-
})
|
|
24
|
-
expect(result).toEqual({
|
|
25
|
-
workouts: [
|
|
26
|
-
{
|
|
27
|
-
_id: 1,
|
|
28
|
-
exercise_id: 1,
|
|
29
|
-
weight_effort: '115lbs',
|
|
30
|
-
reps: 10,
|
|
31
|
-
sets: 3,
|
|
32
|
-
note: '',
|
|
33
|
-
order: 0,
|
|
34
|
-
date: '2024-06-02'
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
_id: 4,
|
|
38
|
-
exercise_id: 1,
|
|
39
|
-
weight_effort: '120lbs',
|
|
40
|
-
reps: 10,
|
|
41
|
-
sets: 3,
|
|
42
|
-
note: '',
|
|
43
|
-
order: 0,
|
|
44
|
-
date: '2024-06-05'
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
_id: 2,
|
|
48
|
-
exercise_id: 2,
|
|
49
|
-
weight_effort: '155lbs',
|
|
50
|
-
reps: 10,
|
|
51
|
-
sets: 3,
|
|
52
|
-
note: '',
|
|
53
|
-
order: 1,
|
|
54
|
-
date: '2024-06-02'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
_id: 5,
|
|
58
|
-
exercise_id: 2,
|
|
59
|
-
weight_effort: '160lbs',
|
|
60
|
-
reps: 10,
|
|
61
|
-
sets: 3,
|
|
62
|
-
note: '',
|
|
63
|
-
order: 1,
|
|
64
|
-
date: '2024-06-05'
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
_id: 3,
|
|
68
|
-
exercise_id: 3,
|
|
69
|
-
weight_effort: '155lbs',
|
|
70
|
-
reps: 10,
|
|
71
|
-
sets: 3,
|
|
72
|
-
note: '',
|
|
73
|
-
order: 2,
|
|
74
|
-
date: '2024-06-02'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
_id: 6,
|
|
78
|
-
exercise_id: 3,
|
|
79
|
-
weight_effort: '160lbs',
|
|
80
|
-
reps: 10,
|
|
81
|
-
sets: 3,
|
|
82
|
-
note: '',
|
|
83
|
-
order: 2,
|
|
84
|
-
date: '2024-06-05'
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
exercises: [
|
|
88
|
-
{ _id: 1, name: 'Bench Press', description: '' },
|
|
89
|
-
{ _id: 2, name: 'Deadlift', description: '' },
|
|
90
|
-
{ _id: 3, name: 'Squat', description: '' }
|
|
91
|
-
]
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
})
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { readEntity } from '../queries/readEntity'
|
|
2
|
-
import { where } from '../queries/where'
|
|
3
|
-
import { splitEntityProperty } from './parsers/splitEntityProperty'
|
|
4
|
-
import siFunciona from 'si-funciona'
|
|
5
|
-
|
|
6
|
-
export const useJoinClause = async (
|
|
7
|
-
{ propertyA = null, comparator = '=', propertyB = null } = {},
|
|
8
|
-
dataSets = {},
|
|
9
|
-
filterJoins = {}
|
|
10
|
-
) => {
|
|
11
|
-
const { entity: entityA, property: propA } = splitEntityProperty(propertyA)
|
|
12
|
-
const { entity: entityB, property: propB } = splitEntityProperty(propertyB)
|
|
13
|
-
|
|
14
|
-
if (!dataSets.hasOwnProperty(entityA)) {
|
|
15
|
-
dataSets = await readEntity(entityA, dataSets)
|
|
16
|
-
}
|
|
17
|
-
if (!dataSets.hasOwnProperty(entityB)) {
|
|
18
|
-
dataSets = await readEntity(entityB, dataSets)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (!filterJoins.hasOwnProperty(entityA)) {
|
|
22
|
-
filterJoins[entityA] = siFunciona.cloneObject(dataSets[entityA])
|
|
23
|
-
}
|
|
24
|
-
if (!filterJoins.hasOwnProperty(entityB)) {
|
|
25
|
-
filterJoins[entityB] = siFunciona.cloneObject(dataSets[entityB])
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
filterJoins[entityA] = filterJoins[entityB].reduce(
|
|
29
|
-
(dataA, dataB) => siFunciona.mergeArrays(
|
|
30
|
-
dataA,
|
|
31
|
-
where(filterJoins[entityA], { property: propA, comparator: comparator, value: dataB[propB] })
|
|
32
|
-
),
|
|
33
|
-
[]
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
filterJoins[entityB] = filterJoins[entityA].reduce(
|
|
37
|
-
(dataB, dataA) => siFunciona.mergeArrays(
|
|
38
|
-
dataB,
|
|
39
|
-
where(filterJoins[entityB], { property: propB, comparator: comparator, value: dataA[propA] })
|
|
40
|
-
),
|
|
41
|
-
[]
|
|
42
|
-
)
|
|
43
|
-
return filterJoins
|
|
44
|
-
}
|
package/src/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare function require (id: string): any
|
package/src/index.test.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { query, create, drop, describe as describeRecord } from './index'
|
|
2
|
-
import { testHelpers } from 'js-build-tools/testHelpers'
|
|
3
|
-
|
|
4
|
-
const databasePath = 'public-api-database/'
|
|
5
|
-
const gulpConfig = testHelpers.gulpConfig
|
|
6
|
-
gulpConfig.set('databasePath', databasePath)
|
|
7
|
-
testHelpers.setDefaults(databasePath)
|
|
8
|
-
|
|
9
|
-
beforeEach(testHelpers.beforeEach)
|
|
10
|
-
|
|
11
|
-
afterEach(testHelpers.afterEach)
|
|
12
|
-
|
|
13
|
-
describe('the public package entry point', () => {
|
|
14
|
-
test('create, insert, read, update, delete, and drop all work through the exported functions', async () => {
|
|
15
|
-
const definition = [
|
|
16
|
-
{ name: '_id', type: 'string', optional: false, autoGenerate: true },
|
|
17
|
-
{ name: 'note', type: 'string', optional: true, autoGenerate: false }
|
|
18
|
-
]
|
|
19
|
-
const keys = [
|
|
20
|
-
{ type: 'primary', fields: ['_id'], lookup: 'pk__id.json' }
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
await create('foo', definition, keys)
|
|
24
|
-
|
|
25
|
-
const inserted = await query("insert foo values note = 'hello'")
|
|
26
|
-
expect(inserted[0]).toHaveLength(1)
|
|
27
|
-
|
|
28
|
-
const read = await query('read foo')
|
|
29
|
-
expect(read[0]).toHaveLength(1)
|
|
30
|
-
expect(read[0][0].note).toBe('hello')
|
|
31
|
-
|
|
32
|
-
const updated = await query("update foo set note = 'updated' where note = 'hello'")
|
|
33
|
-
expect(updated[0][0].note).toBe('updated')
|
|
34
|
-
|
|
35
|
-
const deleted = await query("delete foo where note = 'updated'")
|
|
36
|
-
expect(deleted[0]).toHaveLength(1)
|
|
37
|
-
|
|
38
|
-
const afterDelete = await query('read foo')
|
|
39
|
-
expect(afterDelete[0]).toEqual([])
|
|
40
|
-
|
|
41
|
-
await drop('foo')
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('describe reports a record\'s field definition', async () => {
|
|
45
|
-
const definition = [
|
|
46
|
-
{ name: '_id', type: 'string', optional: false, autoGenerate: true }
|
|
47
|
-
]
|
|
48
|
-
await create('bar', definition, [])
|
|
49
|
-
const result = await describeRecord('bar')
|
|
50
|
-
expect(result).toEqual(definition)
|
|
51
|
-
})
|
|
52
|
-
})
|
package/src/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { query } from './data/queries/query'
|
|
2
|
-
export { create, drop, describe } from './data/introspect'
|
|
3
|
-
export {
|
|
4
|
-
fieldProperties,
|
|
5
|
-
fieldDefinition,
|
|
6
|
-
fieldName,
|
|
7
|
-
keyProperties,
|
|
8
|
-
keyDefinition,
|
|
9
|
-
indexType,
|
|
10
|
-
indexLocation,
|
|
11
|
-
referenceProperties,
|
|
12
|
-
reference,
|
|
13
|
-
recordProperties,
|
|
14
|
-
recordDefinition,
|
|
15
|
-
recordPath,
|
|
16
|
-
entityPath
|
|
17
|
-
} from './data/introspect'
|
package/test-data/__RECORDS.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"path": "",
|
|
3
|
-
"definition": [
|
|
4
|
-
{
|
|
5
|
-
"name": "path",
|
|
6
|
-
"type": "string",
|
|
7
|
-
"optional": false
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"name": "definition",
|
|
11
|
-
"type": "object",
|
|
12
|
-
"optional": false
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "keys",
|
|
16
|
-
"type": "array",
|
|
17
|
-
"optional": false
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"name": "entries",
|
|
21
|
-
"type": "array",
|
|
22
|
-
"optional": false
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"keys": [],
|
|
26
|
-
"entries": [
|
|
27
|
-
"exercise_muscle.json",
|
|
28
|
-
"exercises.json",
|
|
29
|
-
"muscles.json",
|
|
30
|
-
"workouts.json"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"value": 1,
|
|
4
|
-
"record": ["abdominal.json"]
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
"value": 2,
|
|
8
|
-
"record": ["biceps.json"]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"value": 3,
|
|
12
|
-
"record": ["calves.json"]
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"value": 4,
|
|
16
|
-
"record": ["deltoids.json"]
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"value": 5,
|
|
20
|
-
"record": ["erector_spinae.json"]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"value": 6,
|
|
24
|
-
"record": ["forearms.json"]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"value": 7,
|
|
28
|
-
"record": ["gluteas_maximus.json"]
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"value": 8,
|
|
32
|
-
"record": ["hamstrings.json"]
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"value": 9,
|
|
36
|
-
"record": ["latissimus_dorsi.json"]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"value": 10,
|
|
40
|
-
"record": ["obliques.json"]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"value": 11,
|
|
44
|
-
"record": ["pectorals.json"]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"value": 12,
|
|
48
|
-
"record": ["quadriceps.json"]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"value": 13,
|
|
52
|
-
"record": ["trapezius.json"]
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"value": 14,
|
|
56
|
-
"record": ["triceps.json"]
|
|
57
|
-
}
|
|
58
|
-
]
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"value": 1,
|
|
4
|
-
"record": [
|
|
5
|
-
"2024-06-02-001.json",
|
|
6
|
-
"2024-06-05-001.json"
|
|
7
|
-
]
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"value": 2,
|
|
11
|
-
"record": [
|
|
12
|
-
"2024-06-02-002.json",
|
|
13
|
-
"2024-06-05-002.json"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"value": 3,
|
|
18
|
-
"record": [
|
|
19
|
-
"2024-06-02-003.json",
|
|
20
|
-
"2024-06-05-003.json"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
]
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"value": "2024-06-02",
|
|
4
|
-
"record": [
|
|
5
|
-
"2024-06-02-001.json",
|
|
6
|
-
"2024-06-02-002.json",
|
|
7
|
-
"2024-06-02-003.json"
|
|
8
|
-
]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"value": "2024-06-05",
|
|
12
|
-
"record": [
|
|
13
|
-
"2024-06-05-001.json",
|
|
14
|
-
"2024-06-05-002.json",
|
|
15
|
-
"2024-06-05-003.json"
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
]
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"value": 1,
|
|
4
|
-
"record": ["2024-06-02-001.json"]
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
"value": 2,
|
|
8
|
-
"record": ["2024-06-02-001.json"]
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"value": 3,
|
|
12
|
-
"record": ["2024-06-02-001.json"]
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"value": 4,
|
|
16
|
-
"record": ["2024-06-05-001.json"]
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"value": 5,
|
|
20
|
-
"record": ["2024-06-05-001.json"]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"value": 6,
|
|
24
|
-
"record": ["2024-06-05-001.json"]
|
|
25
|
-
}
|
|
26
|
-
]
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import fs from 'fs/promises'
|
|
3
|
-
|
|
4
|
-
export const copyDatabase = async (destination: string = 'test-database'): Promise<Array<string>> => {
|
|
5
|
-
const makeDirs: string[] = [
|
|
6
|
-
'__indexes',
|
|
7
|
-
'__indexes/exercise_muscle',
|
|
8
|
-
'__indexes/exercises',
|
|
9
|
-
'__indexes/muscles',
|
|
10
|
-
'__indexes/workouts',
|
|
11
|
-
'exercise_muscle',
|
|
12
|
-
'exercises',
|
|
13
|
-
'muscles',
|
|
14
|
-
'workouts',
|
|
15
|
-
]
|
|
16
|
-
for (let dir of makeDirs) {
|
|
17
|
-
await fs.mkdir(`${destination}/${dir}`)
|
|
18
|
-
}
|
|
19
|
-
const copyFiles: string[] = [
|
|
20
|
-
'__RECORDS.json',
|
|
21
|
-
'exercise_muscle.json',
|
|
22
|
-
'exercise_muscle/bench_press_pectorals.json',
|
|
23
|
-
'exercise_muscle/deadlift_hamstrings.json',
|
|
24
|
-
'exercise_muscle/squat_quadriceps.json',
|
|
25
|
-
'__indexes/exercise_muscle/fk_exercise_id.json',
|
|
26
|
-
'__indexes/exercise_muscle/fk_muscle_id.json',
|
|
27
|
-
'__indexes/exercise_muscle/pk__id.json',
|
|
28
|
-
'exercises.json',
|
|
29
|
-
'exercises/bench_press.json',
|
|
30
|
-
'exercises/deadlift.json',
|
|
31
|
-
'exercises/squat.json',
|
|
32
|
-
'__indexes/exercises/pk__id.json',
|
|
33
|
-
'muscles.json',
|
|
34
|
-
'muscles/abdominal.json',
|
|
35
|
-
'muscles/biceps.json',
|
|
36
|
-
'muscles/calves.json',
|
|
37
|
-
'muscles/deltoids.json',
|
|
38
|
-
'muscles/erector_spinae.json',
|
|
39
|
-
'muscles/forearms.json',
|
|
40
|
-
'muscles/gluteus_maximus.json',
|
|
41
|
-
'muscles/hamstrings.json',
|
|
42
|
-
'muscles/latissimus_dorsi.json',
|
|
43
|
-
'muscles/obliques.json',
|
|
44
|
-
'muscles/pectorals.json',
|
|
45
|
-
'muscles/quadriceps.json',
|
|
46
|
-
'muscles/trapezius.json',
|
|
47
|
-
'muscles/triceps.json',
|
|
48
|
-
'__indexes/muscles/pk__id.json',
|
|
49
|
-
'workouts.json',
|
|
50
|
-
'workouts/2024-06-02-001.json',
|
|
51
|
-
'workouts/2024-06-02-002.json',
|
|
52
|
-
'workouts/2024-06-02-003.json',
|
|
53
|
-
'workouts/2024-06-05-001.json',
|
|
54
|
-
'workouts/2024-06-05-002.json',
|
|
55
|
-
'workouts/2024-06-05-003.json',
|
|
56
|
-
'__indexes/workouts/fk_exercise_id.json',
|
|
57
|
-
'__indexes/workouts/index_date.json',
|
|
58
|
-
'__indexes/workouts/pk__id.json',
|
|
59
|
-
]
|
|
60
|
-
for (let file of copyFiles) {
|
|
61
|
-
await fs.copyFile(`test-data/${file}`, `${destination}/${file}`)
|
|
62
|
-
}
|
|
63
|
-
return copyFiles
|
|
64
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"path": "exercise_muscle",
|
|
3
|
-
"definition": [
|
|
4
|
-
{
|
|
5
|
-
"name": "_id",
|
|
6
|
-
"type": "string",
|
|
7
|
-
"optional": false
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"name": "exercise_id",
|
|
11
|
-
"type": "string",
|
|
12
|
-
"optional": false
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "muscle_id",
|
|
16
|
-
"type": "string",
|
|
17
|
-
"optional": false
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"name": "muscle_rank",
|
|
21
|
-
"type": "int",
|
|
22
|
-
"optional": false
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"keys": [
|
|
26
|
-
{
|
|
27
|
-
"type": "primary",
|
|
28
|
-
"fields": [
|
|
29
|
-
"_id"
|
|
30
|
-
],
|
|
31
|
-
"lookup": "pk__id.json"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"type": "foreign",
|
|
35
|
-
"fields": [
|
|
36
|
-
"exercise_id"
|
|
37
|
-
],
|
|
38
|
-
"lookup": "fk_exercise_id.json",
|
|
39
|
-
"references": [
|
|
40
|
-
{
|
|
41
|
-
"fields": [
|
|
42
|
-
"exercises._id"
|
|
43
|
-
],
|
|
44
|
-
"lookup": "exercises.json"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"type": "foreign",
|
|
50
|
-
"fields": [
|
|
51
|
-
"muscle_id"
|
|
52
|
-
],
|
|
53
|
-
"lookup": "fk_muscle_id.json",
|
|
54
|
-
"references": [
|
|
55
|
-
{
|
|
56
|
-
"fields": [
|
|
57
|
-
"muscles._id"
|
|
58
|
-
],
|
|
59
|
-
"lookup": "muscles.json"
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"entries": [
|
|
65
|
-
"bench_press_pectorals.json",
|
|
66
|
-
"deadlift_hamstrings.json",
|
|
67
|
-
"squat_quadriceps.json"
|
|
68
|
-
]
|
|
69
|
-
}
|
package/test-data/exercises.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"path": "exercises",
|
|
3
|
-
"definition": [
|
|
4
|
-
{
|
|
5
|
-
"name": "_id",
|
|
6
|
-
"type": "string",
|
|
7
|
-
"optional": false
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"name": "name",
|
|
11
|
-
"type": "string",
|
|
12
|
-
"optional": false
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "description",
|
|
16
|
-
"type": "string",
|
|
17
|
-
"optional": true
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
"keys": [
|
|
21
|
-
{
|
|
22
|
-
"type": "primary",
|
|
23
|
-
"fields": [
|
|
24
|
-
"_id"
|
|
25
|
-
],
|
|
26
|
-
"lookup": "pk__id.json"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"entries": [
|
|
30
|
-
"bench_press.json",
|
|
31
|
-
"deadlift.json",
|
|
32
|
-
"squat.json"
|
|
33
|
-
]
|
|
34
|
-
}
|