Package Exports
- @nano-sql/core
- @nano-sql/core/lib/adapters/memoryIndex
- @nano-sql/core/lib/adapters/webSQL
- @nano-sql/core/lib/interfaces
- @nano-sql/core/lib/utilities
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@nano-sql/core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Universal database for the client, server & mobile devices. It's like Lego for databases.

NOTICE: This is the IN PROGRESS readme for nanoSQL 2.0. Some of these features are not in place yet.
Scroll down for the todo list and it's progress.
nanoSQL is a database abstraction layer that:
- Makes running noSQL a breeze anywhere (NodeJS / Browser / Cordova / React Native / Electron).
- Use nanoSQL standalone, as the glue between your server and clients, or even with multi master servers.
- Supports many advanced features like Graph Queries, Map/Reduce, Indexing, and Geolocations.
- Lets you use almost any database technology (RocksDB, MySQL, SQLite, Amazon Dynamo, etc...).
Identical API Everywhere
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.
Data Model => Typescript Interface
Automatically generate typescript interfaces from your data models.
Offline Syncing
Run nanoSQL on your server and client, then with little effort allow nanoSQL to handle the eventual consistency problems and keep both ends in sync with eachother.
Not Only NoSQL
Classical RDBMS queries like aggregate functions, joins and group bys are also supported.
Flexible Data Models
The best of both worlds: Use RDBMS style data models to tune performance but still allow arbtrary columns. Change your data model as often as you want and do type casting only when you need it.
Other Cool Things
Built in geolocation indexing, query functions, multi-tab sync, typescript support, event system, CSV/JSON import & export, graph query support, and runs in every browser back to IE9!
Live Examples: Express/NodeJS - React - React Native - Angular - Vue - Cordova
Browser Support
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ |
Database Support
NanoSQL can save data to many different places, depending on the browser or environment it's being ran in.
Included In The Box
- Memory
- Rocks DB
- Indexed DB
- WebSQL
- Local Storage
Installation
npm i @nano-sql/core --save
Using in Typescript/Babel project:
import { nSQL } from "@nano-sql/core";
Using in Node:
const nSQL = require("@nano-sql/core").nSQL;
To use directly in the browser, drop the tag below into your <head>
.
<script src="https://cdn.jsdelivr.net/npm/@nano-sql/core@2.0.0-rc17/dist/nano-sql.min.js"></script>
Important
If you are migrating from nanoSQL 1.X to 2.X, please read the migration guide.
2.0 Progress
- Query Engine
- Hook/Filter System
- Memory/Local Storage Adapter
- Graph Query Support
- Event System
- Indexed DB/WebSQL/RocksDB Adapters
- Core Tests
- Adapter Tests
- 2.0 documentation
- 2.0 release
- SQLite3, Cordova, Redis, ReactNative, MySQL, Amazon Dynamo DB Adapters
- GraphQL Support
- Net Plugin (Offline Syncing)
- Search Plugin
- History Plugin
- SQLite Query Support
- MongoDB Query Support
- ReQL Query Support
Examples
// Persistent Database
nSQL().connect({
id: "test",
mode: "PERM",
tables: [
{
name: "users",
model: {
"id:uuid": {pk: true},
"name:string": {},
"age:int": {},
"meta:obj": {
model: {
"color:string": {}
}
},
"tags:string[]": {default: []}
}
indexes: {
"tags:string[]": {},
"meta.color:string": {},
"age:int": {}
}
}
],
}).then(() => {
return nSQL("users").query("upsert", {name: "Jeb", age: 20, meta: {color: "blue"}, tags: ["some", "tags", "here"]}).exec();
}).then(() => {
return nSQL("users").query("select").exec();
}).then((rows) => {
console.log(rows);
/*
[
{
"id": "64c611b8-0b1e-42f6-af52-5b8289834bba",
"name": "Billy",
"age": 21,
"meta": {
"color": "blue"
},
"tags": [
"some",
"tags",
"here"
]
}
]
*/
});
// Graph Queries
nSQL().query("select", ["author[0].name AS author", "body", "comments[0].totalComments AS commentsTotal", "id", "title"]).from({
table: () => fetch("https://jsonplaceholder.typicode.com/posts").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "posts"
}).graph([
{
key: "author",
with: {
table: () => fetch("https://jsonplaceholder.typicode.com/users").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "author"
},
on: ["author.id", "=", "posts.userId"]
},
{
key: "comments",
select: ["COUNT(*) as totalComments"],
with: {
table: () => fetch("https://jsonplaceholder.typicode.com/comments").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "comments"
},
on: ["comments.postId", "=", "posts.id"]
}
]).exec().then((rows) => {
console.log(rows);
/*
"author": "Leanne Graham",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
"commentsTotal": 5,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
},
{
"author": "Leanne Graham",
"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",
"commentsTotal": 5,
"id": 2,
"title": "qui est esse"
}
...
*/
});
// Join Queries
nSQL().query("select", ["posts.id AS id", "posts.title AS title", "comments.name AS comment", "users.name AS name"]).from({
table: () => fetch("https://jsonplaceholder.typicode.com/posts").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "posts"
}).where(["userId", "=", 3]).join([
{
type: "inner",
with: {
table: () => fetch("https://jsonplaceholder.typicode.com/comments").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "comments"
},
on: ["posts.id", "=", "comments.postId"]
},
{
type: "inner",
with: {
table: () => fetch("https://jsonplaceholder.typicode.com/users").then(d => d.json()).then(j => ({rows: j, cache: true})),
as: "users"
},
on: ["users.id", "=", "posts.userId"]
}
])
.exec().then((rows) => {
console.log(rows);
/*
[
{
"id": 21,
"title": "asperiores ea ipsam voluptatibus modi minima quia sint",
"comment": "perspiciatis magnam ut eum autem similique explicabo expedita",
"name": "Clementine Bauch"
},
{
"id": 21,
"title": "asperiores ea ipsam voluptatibus modi minima quia sint",
"comment": "officia ullam ut neque earum ipsa et fuga",
"name": "Clementine Bauch"
},
.....
]
*/
})