@cocreate/indexeddb 1.10.20 → 1.11.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/CHANGELOG.md +20 -0
- package/CoCreate.config.js +2 -2
- package/LICENSE +683 -21
- package/docs/index.html +9 -15
- package/package.json +4 -5
- package/src/index.js +449 -892
- package/test/collections.js +13 -9
- package/test/databases.js +9 -6
- package/test/documents.js +26 -22
- package/test/index.html +1 -1
- package/test/indexes.js +7 -7
- package/webpack.config.js +79 -73
package/test/collections.js
CHANGED
|
@@ -4,30 +4,34 @@ async function testCollections() {
|
|
|
4
4
|
return;
|
|
5
5
|
} else {
|
|
6
6
|
|
|
7
|
-
let createCollection = await CoCreate.indexeddb.
|
|
7
|
+
let createCollection = await CoCreate.indexeddb.process({
|
|
8
|
+
method: 'create.array',
|
|
8
9
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
array: ['testCollection', 'testCollection1', 'testCollection2']
|
|
11
|
+
|
|
11
12
|
})
|
|
12
13
|
console.log('createCollection', createCollection)
|
|
13
14
|
|
|
14
|
-
let readCollection = await CoCreate.indexeddb.
|
|
15
|
+
let readCollection = await CoCreate.indexeddb.process({
|
|
16
|
+
method: 'read.array',
|
|
15
17
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
18
|
})
|
|
17
19
|
console.log('readCollection', readCollection)
|
|
18
20
|
|
|
19
|
-
let updateCollection = await CoCreate.indexeddb.
|
|
21
|
+
let updateCollection = await CoCreate.indexeddb.process({
|
|
22
|
+
method: 'update.array',
|
|
20
23
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
21
|
-
|
|
24
|
+
array: { testCollection: 'testCollectionA' }
|
|
22
25
|
})
|
|
23
26
|
console.log('updateCollection', updateCollection)
|
|
24
27
|
|
|
25
28
|
|
|
26
|
-
let deleteCollection = await CoCreate.indexeddb.
|
|
29
|
+
let deleteCollection = await CoCreate.indexeddb.process({
|
|
30
|
+
method: 'delete.array',
|
|
27
31
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
28
|
-
|
|
32
|
+
array: ['testCollectionA', 'testCollection1', 'testCollection2']
|
|
29
33
|
})
|
|
30
34
|
console.log('deleteCollection', deleteCollection)
|
|
31
|
-
|
|
35
|
+
|
|
32
36
|
}
|
|
33
37
|
}
|
package/test/databases.js
CHANGED
|
@@ -3,27 +3,30 @@ async function testDatabases() {
|
|
|
3
3
|
console.log("This browser doesn't support IndexedDB.");
|
|
4
4
|
return;
|
|
5
5
|
} else {
|
|
6
|
-
let createDatabase = await CoCreate.indexeddb.
|
|
6
|
+
let createDatabase = await CoCreate.indexeddb.process({
|
|
7
|
+
method: 'create.database',
|
|
7
8
|
database: 'testDB',
|
|
8
9
|
})
|
|
9
10
|
console.log('createDatabase', createDatabase)
|
|
10
11
|
|
|
11
|
-
let readDatabase = await CoCreate.indexeddb.
|
|
12
|
+
let readDatabase = await CoCreate.indexeddb.process({
|
|
13
|
+
method: 'read.database',
|
|
12
14
|
database: 'testDB',
|
|
13
15
|
})
|
|
14
16
|
console.log('readDatabase', readDatabase)
|
|
15
17
|
|
|
16
|
-
let updateDatabase = await CoCreate.indexeddb.
|
|
17
|
-
|
|
18
|
+
let updateDatabase = await CoCreate.indexeddb.process({
|
|
19
|
+
method: 'update.database',
|
|
20
|
+
database: { testDB: 'testDatabase1' }
|
|
18
21
|
})
|
|
19
22
|
console.log('updateDatabase', updateDatabase)
|
|
20
23
|
|
|
21
24
|
|
|
22
|
-
let deleteDatabase = await CoCreate.indexeddb.
|
|
25
|
+
let deleteDatabase = await CoCreate.indexeddb.process({
|
|
26
|
+
method: 'delete.database',
|
|
23
27
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
24
28
|
})
|
|
25
29
|
console.log('deleteDatabase', deleteDatabase)
|
|
26
30
|
|
|
27
|
-
|
|
28
31
|
}
|
|
29
32
|
}
|
package/test/documents.js
CHANGED
|
@@ -3,56 +3,60 @@ async function testDocuments() {
|
|
|
3
3
|
console.log("This browser doesn't support IndexedDB.");
|
|
4
4
|
return;
|
|
5
5
|
} else {
|
|
6
|
-
|
|
7
|
-
let createDocument = await CoCreate.indexeddb.
|
|
6
|
+
|
|
7
|
+
let createDocument = await CoCreate.indexeddb.process({
|
|
8
|
+
method: 'create.object',
|
|
8
9
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
11
|
+
object: {
|
|
11
12
|
organization_id: '5ff747727005da1c272740ab',
|
|
12
13
|
'books.action.title': 'matr',
|
|
13
|
-
sports: {basketball: {teams: ['bulls']}}
|
|
14
|
+
sports: { basketball: { teams: ['bulls'] } }
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
})
|
|
17
18
|
console.log('createDocument', createDocument)
|
|
18
|
-
let _id = createDocument.
|
|
19
|
+
let _id = createDocument.object[0]._id
|
|
19
20
|
|
|
20
|
-
let readDocument = await CoCreate.indexeddb.
|
|
21
|
+
let readDocument = await CoCreate.indexeddb.process({
|
|
22
|
+
method: 'read.object',
|
|
21
23
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
25
|
+
object: {
|
|
24
26
|
_id,
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
|
|
27
29
|
})
|
|
28
30
|
console.log('readDocument', readDocument)
|
|
29
31
|
|
|
30
|
-
let updateDocument = await CoCreate.indexeddb.
|
|
32
|
+
let updateDocument = await CoCreate.indexeddb.process({
|
|
33
|
+
method: 'update.object',
|
|
31
34
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
36
|
+
object: {
|
|
34
37
|
_id,
|
|
35
38
|
'books.action.title': 'matr',
|
|
36
|
-
sports: {basketball: {teams: ['lakers']}}
|
|
39
|
+
sports: { basketball: { teams: ['lakers'] } }
|
|
37
40
|
}
|
|
38
|
-
|
|
41
|
+
|
|
39
42
|
})
|
|
40
43
|
console.log('updateDocument', updateDocument)
|
|
41
44
|
|
|
42
45
|
|
|
43
|
-
let deleteDocument = await CoCreate.indexeddb.
|
|
46
|
+
let deleteDocument = await CoCreate.indexeddb.process({
|
|
47
|
+
method: 'delete.object',
|
|
44
48
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
45
|
-
|
|
46
|
-
//
|
|
49
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
50
|
+
// object: {
|
|
47
51
|
// _id
|
|
48
52
|
// }
|
|
49
|
-
filter: {
|
|
53
|
+
filter: {
|
|
50
54
|
query: [
|
|
51
|
-
{
|
|
55
|
+
{ key: 'organization_id', value: "5ff747727005da1c272740ab" }
|
|
52
56
|
]
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
59
|
+
|
|
56
60
|
})
|
|
57
61
|
console.log('deleteDocument', deleteDocument)
|
|
58
62
|
|
package/test/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
19
19
|
<!-- <script src="../dist/CoCreate-indexeddb.js"></script> -->
|
|
20
20
|
<script src="./databases.js"></script>
|
|
21
|
-
<script src="./
|
|
21
|
+
<script src="./arrays.js"></script>
|
|
22
22
|
<script src="./indexes.js"></script>
|
|
23
23
|
<script src="./documents.js"></script>
|
|
24
24
|
</body>
|
package/test/indexes.js
CHANGED
|
@@ -5,31 +5,31 @@ async function testIndexes() {
|
|
|
5
5
|
} else {
|
|
6
6
|
let createIndexes = await CoCreate.indexeddb.createIndex({
|
|
7
7
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
8
|
-
|
|
8
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
9
9
|
index: 'testIndexes'
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
})
|
|
12
12
|
console.log('createIndexes', createIndexes)
|
|
13
13
|
|
|
14
14
|
let readIndexes = await CoCreate.indexeddb.readIndex({
|
|
15
15
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
16
|
-
|
|
16
|
+
array: ['testCollection', 'testCollection1', 'testCollection2']
|
|
17
17
|
})
|
|
18
18
|
console.log('readIndexes', readIndexes)
|
|
19
19
|
|
|
20
20
|
let updateIndexes = await CoCreate.indexeddb.updateIndex({
|
|
21
21
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
22
|
-
|
|
23
|
-
index: {testIndexes: 'testIndexes1'}
|
|
22
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
23
|
+
index: { testIndexes: 'testIndexes1' }
|
|
24
24
|
})
|
|
25
25
|
console.log('updateIndexes', updateIndexes)
|
|
26
26
|
|
|
27
27
|
let deleteIndexes = await CoCreate.indexeddb.deleteIndex({
|
|
28
28
|
database: ['testDB', 'testDB1', 'testDB2'],
|
|
29
|
-
|
|
29
|
+
array: ['testCollection', 'testCollection1', 'testCollection2'],
|
|
30
30
|
index: 'testIndexes1'
|
|
31
31
|
})
|
|
32
32
|
console.log('deleteIndexes', deleteIndexes)
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
}
|
|
35
35
|
}
|
package/webpack.config.js
CHANGED
|
@@ -1,84 +1,90 @@
|
|
|
1
1
|
const path = require("path")
|
|
2
2
|
const TerserPlugin = require("terser-webpack-plugin")
|
|
3
3
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
|
4
|
-
let isProduction = process.env.NODE_ENV === "production"
|
|
5
4
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
|
|
6
5
|
|
|
7
|
-
module.exports = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
output: {
|
|
12
|
-
path: path.resolve(__dirname, "dist"),
|
|
13
|
-
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
14
|
-
libraryTarget: "umd",
|
|
15
|
-
libraryExport: "default",
|
|
16
|
-
library: ["CoCreate", "indexeddb"],
|
|
17
|
-
globalObject: "this",
|
|
18
|
-
},
|
|
6
|
+
module.exports = (env, argv) => {
|
|
7
|
+
let isProduction = false
|
|
8
|
+
if (argv.mode === 'production')
|
|
9
|
+
isProduction = true
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
filename: "[name].css",
|
|
24
|
-
}),
|
|
25
|
-
],
|
|
26
|
-
// Default mode for Webpack is production.
|
|
27
|
-
// Depending on mode Webpack will apply different things
|
|
28
|
-
// on final bundle. For now we don't need production's JavaScript
|
|
29
|
-
// minifying and other thing so let's set mode to development
|
|
30
|
-
mode: isProduction ? "production" : "development",
|
|
31
|
-
module: {
|
|
32
|
-
rules: [
|
|
33
|
-
{
|
|
34
|
-
test: /.js$/,
|
|
35
|
-
exclude: /(node_modules)/,
|
|
36
|
-
use: {
|
|
37
|
-
loader: "babel-loader",
|
|
38
|
-
options: {
|
|
39
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
40
|
-
},
|
|
11
|
+
const config = {
|
|
12
|
+
entry: {
|
|
13
|
+
"CoCreate-indexeddb": "./src/index.js",
|
|
41
14
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
output: {
|
|
16
|
+
path: path.resolve(__dirname, "dist"),
|
|
17
|
+
filename: isProduction ? "[name].min.js" : "[name].js",
|
|
18
|
+
libraryTarget: "umd",
|
|
19
|
+
libraryExport: "default",
|
|
20
|
+
library: ["CoCreate", "indexeddb"],
|
|
21
|
+
globalObject: "this",
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
plugins: [
|
|
25
|
+
new CleanWebpackPlugin(),
|
|
26
|
+
new MiniCssExtractPlugin({
|
|
27
|
+
filename: "[name].css",
|
|
28
|
+
}),
|
|
48
29
|
],
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
30
|
+
// Default mode for Webpack is production.
|
|
31
|
+
// Depending on mode Webpack will apply different things
|
|
32
|
+
// on final bundle. For now we don't need production's JavaScript
|
|
33
|
+
// minifying and other thing so let's set mode to development
|
|
34
|
+
mode: isProduction ? "production" : "development",
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
test: /.js$/,
|
|
39
|
+
exclude: /(node_modules)/,
|
|
40
|
+
use: {
|
|
41
|
+
loader: "babel-loader",
|
|
42
|
+
options: {
|
|
43
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
test: /.css$/i,
|
|
49
|
+
use: [
|
|
50
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
51
|
+
"file-loader",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
// add source map
|
|
58
|
+
...(isProduction ? {} : { devtool: "eval-source-map" }),
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
optimization: {
|
|
61
|
+
minimize: true,
|
|
62
|
+
minimizer: [
|
|
63
|
+
new TerserPlugin({
|
|
64
|
+
extractComments: true,
|
|
65
|
+
// cache: true,
|
|
66
|
+
parallel: true,
|
|
67
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
68
|
+
terserOptions: {
|
|
69
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
70
|
+
// extractComments: 'all',
|
|
71
|
+
compress: {
|
|
72
|
+
drop_console: true,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
],
|
|
77
|
+
splitChunks: {
|
|
78
|
+
chunks: "all",
|
|
79
|
+
minSize: 200,
|
|
80
|
+
// maxSize: 99999,
|
|
81
|
+
//minChunks: 1,
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
83
|
+
cacheGroups: {
|
|
84
|
+
defaultVendors: false,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
return config
|
|
90
|
+
}
|