@cocreate/indexeddb 1.2.10 → 1.3.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.
@@ -0,0 +1,33 @@
1
+ async function testCollections() {
2
+ if (!('indexedDB' in window)) {
3
+ console.log("This browser doesn't support IndexedDB.");
4
+ return;
5
+ } else {
6
+
7
+ let createCollection = await CoCreate.indexeddb.createCollection({
8
+ database: ['testDB', 'testDB1', 'testDB2'],
9
+ collection: ['testCollection', 'testCollection1', 'testCollection2']
10
+
11
+ })
12
+ console.log('createCollection', createCollection)
13
+
14
+ let readCollection = await CoCreate.indexeddb.readCollection({
15
+ database: ['testDB', 'testDB1', 'testDB2'],
16
+ })
17
+ console.log('readCollection', readCollection)
18
+
19
+ let updateCollection = await CoCreate.indexeddb.updateCollection({
20
+ database: ['testDB', 'testDB1', 'testDB2'],
21
+ collection: {testCollection: 'testCollectionA'}
22
+ })
23
+ console.log('updateCollection', updateCollection)
24
+
25
+
26
+ let deleteCollection = await CoCreate.indexeddb.deleteCollection({
27
+ database: ['testDB', 'testDB1', 'testDB2'],
28
+ collection: ['testCollectionA', 'testCollection1', 'testCollection2']
29
+ })
30
+ console.log('deleteCollection', deleteCollection)
31
+
32
+ }
33
+ }
@@ -0,0 +1,31 @@
1
+ async function testDatabases() {
2
+ if (!('indexedDB' in window)) {
3
+ console.log("This browser doesn't support IndexedDB.");
4
+ return;
5
+ } else {
6
+ let createDatabase = await CoCreate.indexeddb.createDatabase({
7
+ database: 'testDB',
8
+
9
+ })
10
+ console.log('createDatabase', createDatabase)
11
+
12
+ let readDatabase = await CoCreate.indexeddb.readDatabase({
13
+ database: 'testDB',
14
+ })
15
+ console.log('readDatabase', readDatabase)
16
+
17
+ // let updateDatabase = await CoCreate.indexeddb.updateDatabase({
18
+ // database: 'testDB',
19
+ // updateDatabase: {testDatabase: 'testDatabase1'}
20
+ // })
21
+ // console.log('updateDatabase', updateDatabase)
22
+
23
+
24
+ let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
25
+ database: 'testDB',
26
+ })
27
+ console.log('deleteDatabase', deleteDatabase)
28
+
29
+
30
+ }
31
+ }
@@ -0,0 +1,64 @@
1
+ async function testDocuments() {
2
+ if (!('indexedDB' in window)) {
3
+ console.log("This browser doesn't support IndexedDB.");
4
+ return;
5
+ } else {
6
+
7
+ let createDocument = await CoCreate.indexeddb.createDocument({
8
+ database: ['testDB', 'testDB1', 'testDB2'],
9
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
10
+ document: {
11
+ organization_id: '5ff747727005da1c272740ab',
12
+ 'books.action.title': 'matr',
13
+ sports: {basketball: {teams: ['bulls']}}
14
+ }
15
+
16
+ })
17
+ console.log('createDocument', createDocument)
18
+ let _id = createDocument.document[0]._id
19
+
20
+ let readDocument = await CoCreate.indexeddb.readDocument({
21
+ database: ['testDB', 'testDB1', 'testDB2'],
22
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
23
+ document: {
24
+ _id,
25
+ }
26
+
27
+ })
28
+ console.log('readDocument', readDocument)
29
+
30
+ let updateDocument = await CoCreate.indexeddb.updateDocument({
31
+ database: ['testDB', 'testDB1', 'testDB2'],
32
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
33
+ document: {
34
+ _id,
35
+ 'books.action.title': 'matr',
36
+ sports: {basketball: {teams: ['lakers']}}
37
+ }
38
+
39
+ })
40
+ console.log('updateDocument', updateDocument)
41
+
42
+
43
+ let deleteDocument = await CoCreate.indexeddb.deleteDocument({
44
+ database: ['testDB', 'testDB1', 'testDB2'],
45
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
46
+ // document: {
47
+ // _id
48
+ // }
49
+ filter: {
50
+ query: [
51
+ {name: 'organization_id', value: "5ff747727005da1c272740ab"}
52
+ ]
53
+ }
54
+
55
+
56
+ })
57
+ console.log('deleteDocument', deleteDocument)
58
+
59
+ // let deleteDatabase = await CoCreate.indexeddb.deleteDatabase({
60
+ // database: ['testDB', 'testDB1', 'testDB2'],
61
+ // })
62
+ // console.log('deleteDatabase', deleteDatabase)
63
+ }
64
+ }
package/test/index.html CHANGED
@@ -12,17 +12,13 @@
12
12
  <body>
13
13
 
14
14
 
15
- <script>
16
- var CoCreateConfig = {
17
- apiKey: '',
18
- organization_Id: '',
19
- host: ''
20
- }
21
- </script>
22
-
23
15
  <!--<script src="https://cdn.cocreate.app/indexeddb/latest/CoCreate-indexeddb.min.js"></script>-->
24
16
  <!-- <script src="../../../CoCreateJS/dist/CoCreate.js"></script> -->
25
17
  <script src="../dist/CoCreate-indexeddb.js"></script>
18
+ <script src="./databases.js"></script>
19
+ <script src="./collections.js"></script>
20
+ <script src="./indexes.js"></script>
21
+ <script src="./documents.js"></script>
26
22
 
27
23
  </body>
28
24
 
@@ -0,0 +1,35 @@
1
+ async function testIndexes() {
2
+ if (!('indexedDB' in window)) {
3
+ console.log("This browser doesn't support IndexedDB.");
4
+ return;
5
+ } else {
6
+ let createIndexes = await CoCreate.indexeddb.createIndex({
7
+ database: ['testDB', 'testDB1', 'testDB2'],
8
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
9
+ index: 'testIndexes'
10
+
11
+ })
12
+ console.log('createIndexes', createIndexes)
13
+
14
+ let readIndexes = await CoCreate.indexeddb.readIndex({
15
+ database: ['testDB', 'testDB1', 'testDB2'],
16
+ collection: ['testCollection', 'testCollection1', 'testCollection2']
17
+ })
18
+ console.log('readIndexes', readIndexes)
19
+
20
+ let updateIndexes = await CoCreate.indexeddb.updateIndex({
21
+ database: ['testDB', 'testDB1', 'testDB2'],
22
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
23
+ index: {testIndexes: 'testIndexes1'}
24
+ })
25
+ console.log('updateIndexes', updateIndexes)
26
+
27
+ let deleteIndexes = await CoCreate.indexeddb.deleteIndex({
28
+ database: ['testDB', 'testDB1', 'testDB2'],
29
+ collection: ['testCollection', 'testCollection1', 'testCollection2'],
30
+ index: 'testIndexes1'
31
+ })
32
+ console.log('deleteIndexes', deleteIndexes)
33
+
34
+ }
35
+ }
package/test/index.js DELETED
@@ -1,31 +0,0 @@
1
- function init() {
2
- if (!('indexedDB' in window)) {
3
- console.log("This browser doesn't support IndexedDB.");
4
- return;
5
- } else {
6
- runTest()
7
- }
8
- }
9
-
10
- async function runTest() {
11
- let data = await CoCreate.indexeddb.createDocument({
12
- database: 'testDB',
13
- collection: 'testCollection',
14
- data: {
15
- name: 'test9'
16
- }
17
- })
18
-
19
- CoCreate.indexeddb.updateDocument({
20
- database: 'testDB',
21
- collection: 'testCollection',
22
- data: {
23
- _id: data.data._id,
24
- 'books.action.title': 'matr',
25
- sports: {basketball: {teams: ['lakers']}}
26
- }
27
-
28
- })
29
- }
30
-
31
- init();