@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.
@@ -4,30 +4,34 @@ async function testCollections() {
4
4
  return;
5
5
  } else {
6
6
 
7
- let createCollection = await CoCreate.indexeddb.createCollection({
7
+ let createCollection = await CoCreate.indexeddb.process({
8
+ method: 'create.array',
8
9
  database: ['testDB', 'testDB1', 'testDB2'],
9
- collection: ['testCollection', 'testCollection1', 'testCollection2']
10
-
10
+ array: ['testCollection', 'testCollection1', 'testCollection2']
11
+
11
12
  })
12
13
  console.log('createCollection', createCollection)
13
14
 
14
- let readCollection = await CoCreate.indexeddb.readCollection({
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.updateCollection({
21
+ let updateCollection = await CoCreate.indexeddb.process({
22
+ method: 'update.array',
20
23
  database: ['testDB', 'testDB1', 'testDB2'],
21
- collection: {testCollection: 'testCollectionA'}
24
+ array: { testCollection: 'testCollectionA' }
22
25
  })
23
26
  console.log('updateCollection', updateCollection)
24
27
 
25
28
 
26
- let deleteCollection = await CoCreate.indexeddb.deleteCollection({
29
+ let deleteCollection = await CoCreate.indexeddb.process({
30
+ method: 'delete.array',
27
31
  database: ['testDB', 'testDB1', 'testDB2'],
28
- collection: ['testCollectionA', 'testCollection1', 'testCollection2']
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.createDatabase({
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.readDatabase({
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.updateDatabase({
17
- database: {testDB: 'testDatabase1'}
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.deleteDatabase({
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.createDocument({
6
+
7
+ let createDocument = await CoCreate.indexeddb.process({
8
+ method: 'create.object',
8
9
  database: ['testDB', 'testDB1', 'testDB2'],
9
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
10
- document: {
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.document[0]._id
19
+ let _id = createDocument.object[0]._id
19
20
 
20
- let readDocument = await CoCreate.indexeddb.readDocument({
21
+ let readDocument = await CoCreate.indexeddb.process({
22
+ method: 'read.object',
21
23
  database: ['testDB', 'testDB1', 'testDB2'],
22
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
23
- document: {
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.updateDocument({
32
+ let updateDocument = await CoCreate.indexeddb.process({
33
+ method: 'update.object',
31
34
  database: ['testDB', 'testDB1', 'testDB2'],
32
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
33
- document: {
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.deleteDocument({
46
+ let deleteDocument = await CoCreate.indexeddb.process({
47
+ method: 'delete.object',
44
48
  database: ['testDB', 'testDB1', 'testDB2'],
45
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
46
- // document: {
49
+ array: ['testCollection', 'testCollection1', 'testCollection2'],
50
+ // object: {
47
51
  // _id
48
52
  // }
49
- filter: {
53
+ filter: {
50
54
  query: [
51
- {name: 'organization_id', value: "5ff747727005da1c272740ab"}
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="./collections.js"></script>
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
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
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
- collection: ['testCollection', 'testCollection1', 'testCollection2']
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
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
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
- collection: ['testCollection', 'testCollection1', 'testCollection2'],
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
- entry: {
9
- "CoCreate-indexeddb": "./src/index.js",
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
- plugins: [
21
- new CleanWebpackPlugin(),
22
- new MiniCssExtractPlugin({
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
- test: /.css$/i,
45
- use: [
46
- { loader: "style-loader", options: { injectType: "linkTag" } },
47
- "file-loader",
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
- // add source map
54
- ...(isProduction ? {} : { devtool: "eval-source-map" }),
57
+ // add source map
58
+ ...(isProduction ? {} : { devtool: "eval-source-map" }),
55
59
 
56
- optimization: {
57
- minimize: true,
58
- minimizer: [
59
- new TerserPlugin({
60
- extractComments: true,
61
- // cache: true,
62
- parallel: true,
63
- // sourceMap: true, // Must be set to true if using source-maps in production
64
- terserOptions: {
65
- // https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
66
- // extractComments: 'all',
67
- compress: {
68
- drop_console: true,
69
- },
70
- },
71
- }),
72
- ],
73
- splitChunks: {
74
- chunks: "all",
75
- minSize: 200,
76
- // maxSize: 99999,
77
- //minChunks: 1,
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
- cacheGroups: {
80
- defaultVendors: false,
81
- },
82
- },
83
- },
84
- }
83
+ cacheGroups: {
84
+ defaultVendors: false,
85
+ },
86
+ },
87
+ },
88
+ }
89
+ return config
90
+ }