Gathering detailed insights and metrics for @nano-sql/core
Gathering detailed insights and metrics for @nano-sql/core
Gathering detailed insights and metrics for @nano-sql/core
Gathering detailed insights and metrics for @nano-sql/core
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
npm install @nano-sql/core
Typescript
Module System
Node Version
NPM Version
TypeScript (95.13%)
Yacc (4.2%)
JavaScript (0.56%)
Shell (0.09%)
CSS (0.01%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
785 Stars
574 Commits
49 Forks
19 Watchers
69 Branches
9 Contributors
Updated on Jun 24, 2025
Latest Version
2.3.7
Package Id
@nano-sql/core@2.3.7
Unpacked Size
1.50 MB
Size
294.76 kB
File Count
76
NPM Version
6.9.2
Node Version
8.12.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
26
3
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Documentation | API Docs | Bugs | Chat
nanoSQL core provides a standardized query language, data modeling, indexing and plugin system that can use almost any database technology for data storage and query; providing a consistent experience across environments and database engines. You can mix and match database backends, query languages and plugins to get the ideal environnement for rapid development.
One of the big items that lead me to build nanoSQL was how NoSQL stores are becoming so popular and performant yet none of them have SQL semantics when you need them. It’s like you have to choose between good performance (noSQL/Document Store) or having stable data modeling with advanced query capability (SQL Style). It seems to me that you can have both, you just have to be aware of the tradeoffs. The big idea here is to build a SQL style parser on top of noSQL datastores. This buys you the strong data models (which is critical in my opinion) of SQL style systems and noSQL level performance if you play inside a small set of rules. You can jump outside those rules whenever you like at the cost of speed…and that’s the point. YOU the developer get to make the choice when and how that happens.
Run several databases in parallel, each database can use it's own backend adapter. This means you could have one nanoSQL instance running a Redis based database, a MySQL based database and a RocksDB based database at the same time seamlessly!
Develop your application with an embedded database like RocksDB, then deploy into production with Redis, Amazon Dynamo, MySQL or many others. nanoSQL even runs in the browser on top of IndexedDB, WebSQL or LocalStorage. All data is portable and all features are isomorphic; jumping between different databases and environments is trivial.
Classical RDBMS queries like aggregate functions, joins and group bys are also supported. You can even write your own query functions and use foreign keys!
The best of both worlds: Use RDBMS style data models to tune performance but still allow arbitrary columns. Change your data model as often as you want and do type casting only when you need it.
Instantly convert nanoSQL data models into typescript interface files.
Use indexing to build nested graph queries on your data with the power of RDBMS and flexibility of noSQL.
Built in geolocation indexing, autocomplete, observable queries, typescript support, event system, CSV/JSON import & export, fuzzy search, runs in every browser back to IE9 and starts at only 30KB!
nanoSQL | TaffyDB | NeDB | LoveField | PouchDB | alaSQL | RxDB | SQL.js | Lunr | |
---|---|---|---|---|---|---|---|---|---|
Events | ✓ | ✓ | ✕ | ✓ | ✓ | ✕ | ✓ | ✕ | ✕ |
Typescript | ✓ | ✕ | ✓ | ✓ | ✓ | ✕ | ✓ | ✓ | ✓ |
Graph Queries | ✓ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ |
Join Queries | ✓ | ✓ | ✓ | ✓ | ✕ | ✓ | ✕ | ✓ | ✕ |
IndexedDB | ✓ | ✕ | ✕ | ✓ | ✓ | ✓ | ✓ | ✕ | ✕ |
NodeJS | ✓ | ✓ | ✓ | ✕ | ✓ | ✓ | ✓ | ✓ | ✓ |
Foreign Keys | ✓ | ✕ | ✕ | ✓ | ✕ | ✓ | ✕ | ✓ | ✕ |
Query Functions | ✓ | ✕ | ✕ | ✕ | ✕ | ✓ | ✕ | ✓ | ✕ |
Custom Backends | ✓ | ✕ | ✕ | ✕ | ✓ | ✕ | ✓ | ✕ | ✕ |
Fuzzy Search * | ✓ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✕ | ✓ |
Size (kb) | 30 | 5 | 27 | 40 | 46 | 88 | 164 | 500 | 8 |
* Requires additional plugin not included in the bundle size shown in the table.
NanoSQL can save data to many different places, depending on the browser or environment it's being ran in.
Included In The Box
1npm i @nano-sql/core --save
Using in Typescript/Babel project:
1import { nSQL } from "@nano-sql/core";
Using in Node:
1const nSQL = require("@nano-sql/core").nSQL;
To use directly in the browser, drop one of the tags below into your <head>
.
1<!-- ES6 Only (Faster & Smaller) --> 2<script src="https://cdn.jsdelivr.net/npm/@nano-sql/core@2.3.7/dist/nano-sql.min.js" integrity="sha256-W1pVgKda7GC4fwXqq9jfOrssBDJJXZqck+ultRPVzmc=" crossorigin="anonymous"></script> 3<!-- ES5 (Internet Explorer/Old Browser Support) --> 4<!-- Promise must be polyfilled as well --> 5<script src="https://cdn.jsdelivr.net/npm/@nano-sql/core@2.3.7/dist/nano-sql.min.es5.js" integrity="sha256-1t9VlpFUgHaxlLQy6HM9ROQvTiuUv2M12Fp1oTh3+yg=" crossorigin="anonymous"></script>
If you are migrating from nanoSQL 1.X to 2.X, please read the migration guide.
1// Persistent Database 2nSQL().createDatabase({ 3 id: "test", 4 mode: "PERM", 5 tables: [ 6 { 7 name: "users", 8 model: { 9 "id:uuid": {pk: true}, 10 "name:string": {}, 11 "age:int": {}, 12 "meta:obj": { 13 model: { 14 "color:string": {} 15 } 16 }, 17 "tags:string[]": {default: []} 18 } 19 indexes: { 20 "tags:string[]": {}, 21 "meta.color:string": {}, 22 "age:int": {} 23 } 24 } 25 ], 26}).then(() => { 27 return nSQL("users").query("upsert", {name: "Jeb", age: 20, meta: {color: "blue"}, tags: ["some", "tags", "here"]}).exec(); 28}).then(() => { 29 return nSQL("users").query("select").exec(); 30}).then((rows) => { 31 console.log(rows); 32 /* 33 [ 34 { 35 "id": "64c611b8-0b1e-42f6-af52-5b8289834bba", 36 "name": "Billy", 37 "age": 21, 38 "meta": { 39 "color": "blue" 40 }, 41 "tags": [ 42 "some", 43 "tags", 44 "here" 45 ] 46 } 47 ] 48 */ 49}); 50 51// Graph Queries 52nSQL().query("select", ["author[0].name AS author", "body", "comments[0].totalComments AS commentsTotal", "id", "title"]).from({ 53 table: () => fetch("https://jsonplaceholder.typicode.com/posts").then(d => d.json()).then(j => ({rows: j, cache: true})), 54 as: "posts" 55}).graph([ 56 { 57 key: "author", 58 with: { 59 table: () => fetch("https://jsonplaceholder.typicode.com/users").then(d => d.json()).then(j => ({rows: j, cache: true})), 60 as: "author" 61 }, 62 on: ["author.id", "=", "posts.userId"] 63 }, 64 { 65 key: "comments", 66 select: ["COUNT(*) as totalComments"], 67 with: { 68 table: () => fetch("https://jsonplaceholder.typicode.com/comments").then(d => d.json()).then(j => ({rows: j, cache: true})), 69 as: "comments" 70 }, 71 on: ["comments.postId", "=", "posts.id"] 72 } 73]).exec().then((rows) => { 74 console.log(rows); 75 /* 76 "author": "Leanne Graham", 77 "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto", 78 "commentsTotal": 5, 79 "id": 1, 80 "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit" 81 }, 82 { 83 "author": "Leanne Graham", 84 "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla", 85 "commentsTotal": 5, 86 "id": 2, 87 "title": "qui est esse" 88 } 89 ... 90 */ 91}); 92 93// Join Queries 94nSQL().query("select", ["posts.id AS id", "posts.title AS title", "comments.name AS comment", "users.name AS name"]).from({ 95 table: () => fetch("https://jsonplaceholder.typicode.com/posts").then(d => d.json()).then(j => ({rows: j, cache: true})), 96 as: "posts" 97}).where(["userId", "=", 3]).join([ 98 { 99 type: "inner", 100 with: { 101 table: () => fetch("https://jsonplaceholder.typicode.com/comments").then(d => d.json()).then(j => ({rows: j, cache: true})), 102 as: "comments" 103 }, 104 on: ["posts.id", "=", "comments.postId"] 105 }, 106 { 107 type: "inner", 108 with: { 109 table: () => fetch("https://jsonplaceholder.typicode.com/users").then(d => d.json()).then(j => ({rows: j, cache: true})), 110 as: "users" 111 }, 112 on: ["users.id", "=", "posts.userId"] 113 } 114]) 115.exec().then((rows) => { 116 console.log(rows); 117 /* 118 [ 119 { 120 "id": 21, 121 "title": "asperiores ea ipsam voluptatibus modi minima quia sint", 122 "comment": "perspiciatis magnam ut eum autem similique explicabo expedita", 123 "name": "Clementine Bauch" 124 }, 125 { 126 "id": 21, 127 "title": "asperiores ea ipsam voluptatibus modi minima quia sint", 128 "comment": "officia ullam ut neque earum ipsa et fuga", 129 "name": "Clementine Bauch" 130 }, 131 ..... 132 ] 133 */ 134})
The nanoSQL command line interface allows you to compile data models into typescript interface files.
Usage is as follows:
1nsql --outDir www --files file1.ts file2.ts... --watch
If you don't pass --watch
the CLI will compile the files into the given directory, then exit. You can also optionally pass --watchPolling
with an interval to enable polling on the watch system.
It's important to note the files must be formatted specifically for the CLI to read them correctly.
Each file should have an export named tables
that is an array of InanoSQLTableConfig
types. The file below is a working example:
1import { InanoSQLTableConfig } from "@nano-sql/core/lib/interfaces"; 2 3export const tables: InanoSQLTableConfig[] = [ 4 { 5 name: "users", 6 model: { 7 "id:uuid": {pk: true}, 8 "age:float": {notNull: true}, 9 "name:string[]": {default: []}, 10 "properties:meta[]": {}, 11 "address:obj": { 12 model: { 13 "street:string":{}, 14 "city:string":{}, 15 "zip:string":{}, 16 "state:string":{} 17 } 18 }, 19 "*:any": {} 20 } 21 } 22]; 23 24export const types = { 25 meta: { 26 "key:string": {notNull: true}, 27 "value:any": {notNull: true} 28 } 29} 30 31// using the above object in nSQL 32import { nSQL } from "@nano-sql/core"; 33nSQL().createDatabase({ 34 id: "my_db", 35 tables: tables, 36 types: types 37}).then..
Assuming the above file is in the root directory of our project named index.ts, we could compile it to a typescript interface file with this command:
1nsql --outDir www --files index.ts
The above command would produce the following file:
1import { uuid, timeId, timeIdms } from "@nano-sql/core/lib/interfaces"; 2 3export interface ItableUsers { 4 id:uuid; 5 age:number; 6 name:string[]; 7 properties?:ItypeMeta[]; 8 address?:{ 9 street?:string; 10 city?:string; 11 zip?:string; 12 state?:string; 13 }; 14 [key: string]: any; 15} 16 17export interface ItypeMeta { 18 key:string; 19 value:any; 20} 21
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/8 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
194 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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