Installations
npm install @prezentor/dexie-observable
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.5.0
NPM Version
6.14.5
Score
74.8
Supply Chain
99
Quality
75.2
Maintenance
50
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (53.7%)
TypeScript (45.34%)
Shell (0.53%)
HTML (0.43%)
Developer
Download Statistics
Total Downloads
388
Last Day
1
Last Week
2
Last Month
3
Last Year
38
GitHub Statistics
12,089 Stars
2,510 Commits
646 Forks
110 Watching
151 Branches
92 Contributors
Bundle Size
12.96 kB
Minified
4.18 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0-beta.7
Package Id
@prezentor/dexie-observable@1.0.0-beta.7
Unpacked Size
296.01 kB
Size
76.66 kB
File Count
12
NPM Version
6.14.5
Node Version
14.5.0
Total Downloads
Cumulative downloads
Total Downloads
388
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
0%
3
Compared to previous month
Last year
-65.5%
38
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dexie.Observable.js
Observe changes to database - even when they happen in another browser window.
Install
npm install dexie --save
npm install dexie-observable --save
Use
1import Dexie from 'dexie'; 2import 'dexie-observable'; 3 4// Use Dexie as normally - but you can also subscribe to db.on('changes'). 5
Usage with existing DB
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.
Dependency Tree
Source
Description
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.
Extended Methods, Properties and Events
UUID key generator
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.
Dexie.Observable.createUUID()
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.
db.on('changes') event
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. |
Example (here we're using plain ES6 script tags):
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>
Change internal timers state
1import Dexie from 'dexie'; 2import 'dexie-observable'; 3Dexie.Observable._timers = { 4 LOCAL_POLL: 1500, 5 NODE_TIMEOUT: 30000 6}
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
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0
Reason
Found 5/19 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/dexie/Dexie.js/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/dexie/Dexie.js/main.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/dexie/Dexie.js/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/dexie/Dexie.js/main.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 21 are checked with a SAST tool
Reason
61 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-3xgx-r9j4-qw9w
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-hpx4-r86g-5jrg
- Warn: Project is vulnerable to: GHSA-prr3-c3m5-p7q2
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w
- Warn: Project is vulnerable to: GHSA-q9mw-68c2-j6m5
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-3q56-9cc2-46j4
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
Score
4.7
/10
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