Gathering detailed insights and metrics for f-dexie-observable
Gathering detailed insights and metrics for f-dexie-observable
Gathering detailed insights and metrics for f-dexie-observable
Gathering detailed insights and metrics for f-dexie-observable
npm install f-dexie-observable
Typescript
Module System
Node Version
NPM Version
JavaScript (53.7%)
TypeScript (45.34%)
Shell (0.53%)
HTML (0.43%)
Total Downloads
487
Last Day
1
Last Week
1
Last Month
3
Last Year
39
12,048 Stars
2,510 Commits
646 Forks
110 Watching
151 Branches
92 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.0-beta.5
Package Id
f-dexie-observable@1.0.0-beta.5
Unpacked Size
345.24 kB
Size
89.95 kB
File Count
11
NPM Version
6.4.1
Node Version
10.14.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
1
Compared to previous week
Last month
50%
3
Compared to previous month
Last year
-59.8%
39
Compared to previous year
Observe changes to database - even when they happen in another browser window.
npm install dexie --save
npm install dexie-observable --save
1import Dexie from 'dexie'; 2import 'dexie-observable'; 3 4// Use Dexie as normally - but you can also subscribe to db.on('changes'). 5
In case you want to use Dexie.Observable with your existing database, you will have to do a schema upgrade. Without it Dexie.Observable will not be able to properly work.
1import Dexie from 'dexie'; 2import 'dexie-observable'; 3 4var db = new Dexie('myExistingDb'); 5db.version(1).stores(... existing schema ...); 6 7// Now, add another version, just to trigger an upgrade for Dexie.Observable 8db.version(2).stores({}); // No need to add / remove tables. This is just to allow the addon to install its tables.
Dexie.Observable is an add-on to Dexie.js makes it possible to listen for changes on the database even if the changes are made in a foreign window. The addon provides a "storage" event for IndexedDB, much like the storage event (onstorage) for localStorage.
In contrary to the Dexie CRUD hooks, this event reacts not only on changes made on the current db instance but also on changes occurring on db instances in other browser windows. This enables a Web Apps to react to database changes and update their views accordingly.
Dexie.Observable is also the base of Dexie.Syncable.js - an add-on that enables two-way replication with a remote server.
When defining your stores in Version.stores() you may use the $$ (double dollar) prefix to your primary key. This will make it auto-generated to a UUID string. See sample below.
A static method added to Dexie that creates a UUID. This method is used internally when using the $$ prefix to primary keys. To change the format of $$ primary keys, just override Dexie.createUUID by setting it to your desired function instead.
Subscribe to any database changes no matter if they occur locally or in other browser window.
Parameters to your callback:
changes : Array<DatabaseChange> | Array of changes that have occured in database (locally or in other window) since last time event was triggered, or the time of starting subscribing to changes. |
partial: Boolean | True in case the array does not contain all changes. In this case, your callback will soon be called again with the additional changes and partial=false when all changes are delivered. |
1<html> 2 <head> 3 <script src="dexie.min.js"></script> 4 <script src="dexie-observable.min.js"></script> <!-- Enable DB observation --> 5 <script> 6 var db = new Dexie("ObservableTest"); 7 db.version(1).stores({ 8 friends: "$$uuid,name" 9 }); 10 db.on('changes', function (changes) { 11 changes.forEach(function (change) { 12 switch (change.type) { 13 case 1: // CREATED 14 console.log('An object was created: ' + JSON.stringify(change.obj); 15 break; 16 case 2: // UPDATED 17 console.log('An object with key ' + change.key + ' was updated with modifications: ' + JSON.stringify(change.mods)); 18 break; 19 case 3: // DELETED 20 console.log('An object was deleted: ' + JSON.stringify(change.oldObj); 21 break; 22 }); 23 }); 24 db.open(); 25 // Make an initial put() - will result in a CREATE-change: 26 db.friends.put({name: "Kalle"}).then(function(primKey) { 27 // Call put() with existing primary key - will result in an UPDATE-change: 28 db.friends.put({uuid: primKey, name: "Olle"}).then (function () { 29 // Call delete() will result in a DELETE-change: 30 db.friends.delete(primKey); 31 }); 32 }); 33 34 // Result that will be logged: 35 // An object was created: {"uuid": "23bada36-d27a-4e78-a978-1ab3c4129cd0", name: "Kalle"} 36 // An object with key: 23bada36-d27a-4e78-a978-1ab3c4129cd0 was updated with modifications: {"name": "Olle"} 37 // An object was deleted: {"uuid": "23bada36-d27a-4e78-a978-1ab3c4129cd0", name: "Olle"} 38 </script> 39 </head> 40 <body> 41 </body> 42</html>
No vulnerabilities found.
Reason
21 commit(s) and 19 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/19 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More