Gathering detailed insights and metrics for mol_db
Gathering detailed insights and metrics for mol_db
npm install mol_db
Typescript
Module System
Node Version
NPM Version
75.1
Supply Chain
96.7
Quality
94.6
Maintenance
100
Vulnerability
98.6
License
Total Downloads
271,297
Last Day
158
Last Week
915
Last Month
4,017
Last Year
49,138
Minified
Minified + Gzipped
Latest Version
0.0.1309
Package Id
mol_db@0.0.1309
Unpacked Size
972.62 kB
Size
183.03 kB
File Count
26
NPM Version
10.8.2
Node Version
20.18.2
Publised On
01 Feb 2025
Cumulative downloads
Total Downloads
Last day
-41.7%
158
Compared to previous day
Last week
-19.7%
915
Compared to previous week
Last month
-14.5%
4,017
Compared to previous month
Last year
-70.5%
49,138
Compared to previous year
2
Static typed facade for IndexedDB with simple API.
1type User = { 2 name: string 3 admin: boolean 4} 5 6// Static typed schema 7type DB = { 8 User: { 9 Key: [ string ] 10 Doc: User 11 Indexes: { 12 Name: [ string ] 13 } 14 } 15} 16 17// Automatic migrations 18const db = await $mol_db< DB >( '$my_app', 19 mig => mig.store_make( 'User' ), 20 mig => { 21 const { User } = mig.stores 22 User.index_make( 'Name', [ 'name' ] ) 23 }, 24) 25 26// Writing transaction 27const { User } = db.change( 'User' ).stores 28await User.put({ name: 'Jin', admin: true }) 29 30// Reading transaction 31const { Name } = db.read( 'User' ).User.indexes 32const jins = await Name.select([ 'Jin' ])
1type ACME = { 2 Users: { 3 Key: number 4 Doc: { 5 name: { 6 first: string 7 last: string 8 } 9 age: number 10 } 11 Indexes: { 12 names: [ string, string ] 13 ages: [ number ] 14 } 15 } 16 Articles: { 17 Key: string 18 Doc: { 19 title: string 20 content: string 21 } 22 Indexes: { 23 full: [ string, string ] 24 } 25 } 26}
1const db = await $$.$mol_db< ACME >( 'ACME' )
1const db = await $$.$mol_db< ACME >( 'ACME', 2 mig => mig.store_make( 'Users' ), 3 mig => mig.stores.Users.index_make( 'ages', [ 'age' ] ), 4 mig => mig.stores.Users.index_make( 'names', [ 'name.first', 'name.last' ], true ), 5 mig => mig.store_make( 'Articles' ), 6 mig => mig.stores.Articles.index_make( 'full', [ 'title', 'content' ] ), 7 // mig => mig.stores.Articles.index_drop( 'full' ), 8 // mig => mig.store_drop( 'Articles' ), 9)
There is 5 migrations. And DB version is 6. After uncommenting last 2 rows, it applies 2 additional migrations and DB version will be 8.
1db.destructor()
1db.kill()
1const { Users, Articles } = db.read( 'Users', 'Articles' )
1const trans = db.change( 'Users', 'Articles' ) 2const { Users, Articles } = trans.stores 3 4// ... 5 6trans.abort() 7// or 8await trans.commit()
Uncommitted transaction without errors will be committed automatically. Any modification error aborts transaction.
1const key = await Users.put({ 2 first: 'Jin', 3 last: 'Nin', 4 age: 36, 5})
1await Users.put( { 2 first: 'Jin', 3 last: 'Nin', 4 age: 37, 5}, 1 )
1const user = await Users.get( 1 )
1const users = await Users.get( $mol_dom_context.IDBKeyRange.bound( 10, 50 ), 10 )
1const count = await Users.count( $mol_dom_context.IDBKeyRange.bound( 10, 50 ) )
1const { names, ages } = users.indexes
1const user = await names.get([ 'Jin', 'Nin' ])
1const users = await ages.get( [ 18 ], 10 )
1const count = await Users.count([ 18 ])
npm install mol_db
1import { $mol_db } from 'mol_db'
No vulnerabilities found.
No security vulnerabilities found.