From 8d27f7be572eff7adc38344ae5d99f042b6208c6 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:27:13 +0100 Subject: [PATCH 01/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a2947d..356797f 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Based on the installation path above. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ``` -2. Create a `src/store.js` file: +2. Create a `store.js` file: ```js // Import Dexie.js @@ -91,7 +91,7 @@ Based on the installation path above. export { db, sync } ``` -3. Use the database according to the [Dexie.js documentation](https://dexie.org/), example `src/main.(js|ts|jsx)` file: +3. Use the database according to the [Dexie.js documentation](https://dexie.org/), example `main.js` file: ```js import { db } from './store' From 7cc3d8b6fd36837349e0142033ce7976bb1fd985 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:28:47 +0100 Subject: [PATCH 02/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 356797f..c46ac5b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Based on the installation path above. ) ``` -Run `npm run dev` and see the task list from `testdata.sql` being logged to the console. +Run `npm run dev` and see the task list from `testdata.sql` plus the new task being logged to the console. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From 8a1b876ed630bf05feffaa2b3d37303738ce1a67 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:31:23 +0100 Subject: [PATCH 03/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c46ac5b..d47e391 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Based on the installation path above. ) ``` -Run `npm run dev` and see the task list from `testdata.sql` plus the new task being logged to the console. +Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From 0ae7622cad55f8caae60a51b743bf72d76220bd4 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:33:55 +0100 Subject: [PATCH 04/13] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d47e391..b8dd7f6 100644 --- a/README.md +++ b/README.md @@ -96,12 +96,14 @@ Based on the installation path above. ```js import { db } from './store' db.tasks.add({ title: 'New Task' }).then( - db.tasks.where('$deleted').notEqual(1).toArray().then(console.log) + db.tasks.where('$deleted').notEqual(1).sortBy('$created').reverse().then(console.log) ) ``` Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. +Open phpMyAdmin at http://localhost:8080, login with root:root and take a look how the data is synchronized. + The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. ## Function Details From 1d03cb49fe7692621deb9a7d7a9e8d83d49d998e Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:34:21 +0100 Subject: [PATCH 05/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8dd7f6..3863bd6 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Based on the installation path above. Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. -Open phpMyAdmin at http://localhost:8080, login with root:root and take a look how the data is synchronized. +Open phpMyAdmin at http://localhost:8080, login with root:root and take a look how the data has been synchronized. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From 4d612951de897bf876d991234581e2ccccf8e89d Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:34:57 +0100 Subject: [PATCH 06/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3863bd6..ee1673f 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Based on the installation path above. Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. -Open phpMyAdmin at http://localhost:8080, login with root:root and take a look how the data has been synchronized. +Open phpMyAdmin at http://localhost:8080, login with root:root and take a look at the data. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From 9299e04653b41d6b72683b32ea1636cca4324102 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:37:20 +0100 Subject: [PATCH 07/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee1673f..659a63e 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Based on the installation path above. ```js import { db } from './store' db.tasks.add({ title: 'New Task' }).then( - db.tasks.where('$deleted').notEqual(1).sortBy('$created').reverse().then(console.log) + db.tasks.where('$deleted').notEqual(1).reverse().sortBy('$created').then(console.log) ) ``` From 214159f53d64a4ff80c450bd2bcef8121b7ce5c9 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:38:11 +0100 Subject: [PATCH 08/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 659a63e..f49f8b2 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Based on the installation path above. Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. -Open phpMyAdmin at http://localhost:8080, login with root:root and take a look at the data. +Open phpMyAdmin at http://localhost:8080, login with root:root and take a look at the database. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From 62e3f35f9cfb2c7b33754e656c8e36d5fe7c0bd3 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:38:32 +0100 Subject: [PATCH 09/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f49f8b2..b613a48 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ Based on the installation path above. Run `npm run dev`, open http://localhost:5173 and see how the task list is logged to the console. -Open phpMyAdmin at http://localhost:8080, login with root:root and take a look at the database. +Open phpMyAdmin at http://localhost:8080, login with `root`:`root` and take a look at the database. The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. From dc2274aa28ba2475349eb1b57174c55636b36218 Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:43:02 +0100 Subject: [PATCH 10/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b613a48..a915bb7 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,8 @@ Open phpMyAdmin at http://localhost:8080, login with `root`:`root` and take a lo The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. +When the user is authenticated with `login()`, new records will get the `userId` property automatically and all `read`, `list`, `update` and `delete` requests are limited to the users records. Detailed documentation: [Multi Tenancy Documentation](https://github.com/mevdschee/php-crud-api#multi-tenancy-support). + ## Function Details ### useSync(endpoint) From 680eee9ec65748a11654759b28f9accf055e245d Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:43:39 +0100 Subject: [PATCH 11/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a915bb7..c6f0dee 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ Open phpMyAdmin at http://localhost:8080, login with `root`:`root` and take a lo The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and `$synchronized` are set and updated automatically, you do not need to modify them manually. By default, UUIDv4 is used for new ids. -When the user is authenticated with `login()`, new records will get the `userId` property automatically and all `read`, `list`, `update` and `delete` requests are limited to the users records. Detailed documentation: [Multi Tenancy Documentation](https://github.com/mevdschee/php-crud-api#multi-tenancy-support). +When the user is authenticated with `login()`, new records will get the `userId` property automatically and all `read`, `list`, `update` and `delete` requests are limited to the users records (see [Multi Tenancy Documentation](https://github.com/mevdschee/php-crud-api#multi-tenancy-support)). ## Function Details From 2b60640d91369251d183148aea9f82fea584666f Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:46:47 +0100 Subject: [PATCH 12/13] Update README.md --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c6f0dee..a8ed519 100644 --- a/README.md +++ b/README.md @@ -108,19 +108,22 @@ The required properties `id`, `userId`, `$created`, `$updated`, `$deleted` and ` When the user is authenticated with `login()`, new records will get the `userId` property automatically and all `read`, `list`, `update` and `delete` requests are limited to the users records (see [Multi Tenancy Documentation](https://github.com/mevdschee/php-crud-api#multi-tenancy-support)). -## Function Details +## Class Details -### useSync(endpoint) +### Sync(endpoint) Intializes the synchronization API. - `endpoint`: ``, *optional*, [PHP CRUD API](https://github.com/mevdschee/php-crud-api?tab=readme-ov-file#installation) endpoint, internal or external, default `/api.php` ```js -const sync = useSync() +import Sync from 'dexie-mysql-sync' +const sync = new Sync() ``` -#### sync.add(table, path, options) +## Function Details + +### sync.add(table, path, options) Starts the synchronization to and from remote. Multiple browser windows are supported. @@ -142,37 +145,37 @@ A local table can be synchronized with only one remote table. A remote table can be synchronized with one or more local tables. -#### sync.emptyTable(table) +### sync.emptyTable(table) Removes all records from a local table without synchronizing them as deleted to the server. - `table`: [Dexie.js Table](https://dexie.org/docs/Dexie/Dexie.%5Btable%5D) -#### sync.reset() +### sync.reset() Resets all synchronizations. All local and remote documents are synchronized again. - `database`: [Dexie.js Database](https://dexie.org/docs/Dexie/Dexie) -#### sync.register(username, password) +### sync.register(username, password) Creates a new user. -#### sync.login(username, password) +### sync.login(username, password) Logs the user in, clears all local tables and resets the synchronization. -#### sync.password(username, password, newPassword) +### sync.password(username, password, newPassword) Updates the password of the user. -#### sync.user(callback) +### sync.user(callback) Returns the use details or null. - `callback`: `` *optional*, callback on any user change with user details or null -#### sync.logout() +### sync.logout() Logs the user out, clears all local tables and resets the synchronization. From 06b4117ce9e60c3642410f1d99b195b39b154f0b Mon Sep 17 00:00:00 2001 From: scriptPilot Date: Sun, 3 Mar 2024 23:48:05 +0100 Subject: [PATCH 13/13] 5.0.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00ace50..13b500e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dexie-mysql-sync", - "version": "5.0.0", + "version": "5.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dexie-mysql-sync", - "version": "5.0.0", + "version": "5.0.1", "license": "MIT", "dependencies": { "js-crud-api": "^0.4.0", diff --git a/package.json b/package.json index d338ca9..13ad05e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dexie-mysql-sync", - "version": "5.0.0", + "version": "5.0.1", "description": "", "main": "lib/index.js", "type": "module",