NoSQL Everywhere
- Makes running noSQL a breeze anywhere (NodeJS / Browser / Cordova / React Native / Electron).
- Lets you scale faster by moving query logic to your application server.
- Supports many advanced features like ORM, Map/Reduce, Indexing, Geolocations and Fuzzy Search.
Develop your application with a simple database like LevelDB, then deploy into production with Redis, Google Cloud Datastore, 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.
NanoSQL includes a full ORM system, secondary indexes, Map/Reduce, fuzzy document search and denormalization helpers to make high performance data modeling simple and easy.
Classical RDBMS queries like aggregate functions, joins and group bys are also supported.
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.
Built in geolocation helpers, undo/redo, multi-tab sync, automatic live backups, typescript support, full event system, CSV/JSON import & export, and runs in every browser back to IE9!
Wait a second, how can all these features be isomorphic and work with simple databases like Redis, LevelDB and LocalStorage?
NanoSQL treats every database backend it uses as nothing more than a key/value store; all features are built ontop of that assumption alone. If it's atleast a key/value store nanoSQL can run ontop of it with no feature loss. For example, secondary indexes are always implemented as a seperate table that acts as an inverted index (even in something like MySQL). Secondary index reads then involve two seperate reads: one of the inverted index table then another from the actual data table. Since both of these reads are jumping directly to keys in the key/value stores or primary keys in RDBMS backends the reads are crazy fast and remain fast regardless of the table sizes. If you avoid full table scans nanoSQL's reads are almost always orders of magnitude faster than sending similar queries to the database it's sitting ontop of.
Live Examples: Express/NodeJS - React - React Native - Angular - Vue - Cordova
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 9+ ✔ |
NanoSQL can save data to many different places, depending on the browser or environment it's being ran in.
-
Included In The Box
- Memory
- Level DB
- Indexed DB
- WebSQL
- Local Storage
npm i nano-sql --save
Using in Typescript/Babel project:
import { nSQL } from "nano-sql";
Using in Node:
const nSQL = require("nano-sql").nSQL;
To use directly in the browser, drop the tag below into your <head>
.
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/nano-sql.min.js"></script>
Organize or filter existing arrays of row data:
nSQL([
{name: "bill", age: 20},
{name: "bob", age: 25},
{name: "jeb", age: 27}
]).query("select", ["name", "MAX(age) AS age"]).exec().then((rows) => {
console.log(rows); // <= [{name: "jeb", age: 27}]
})
Use as a database:
nSQL('users') // "users" is our table name.
.model([ // Declare data model
{key: 'id', type: 'uuid', props:['pk']}, // pk == primary key,
{key: 'name', type: 'string'}, // name column, string
{key: 'age', type: 'int'}, // age column, integer
{key: '*', type: '*'} // allow any other columns of any type
])
.config({ // set configuration options (only need to do this once)
id: "KSP"
})
.connect() // Init the data store for usage. (only need to do this once)
.then((result) => {
return nSQL("users").query("upsert", { // Add a record
name:"bill",
age: 20,
somethingElse: "yo"
}).exec();
})
.then((result) => {
return nSQL("users").query("select").exec(); // select all rows
})
.then((result) => {
console.log(result) // <= [{id:"93716b41-7e71-4c55-bf5e-bd1cf09416c9", name:"bill", age: 20, somethingElse: "yo"}]
})
All features are universal/isomorphic and work with any database adapter.
Advanced Document Search
Have lots of data that needs searching? Many concepts have been taken from Apache Solr/ElasticSearch then streamlined and implimented in nanoSQL.
example code
ORM (Object Relation Mapping)
Just because we're running No-SQL doesn't mean we can't have relationships.
example code
Observables
Use the observable pattern to wire your application views to database queries with ease.
example code
Multi Tab Support
Want two browser tabs to remain in sync? With a single config change nanoSQL can keep two tabs in perfect sync.
example code
Denormalization & Map/Reduce
Get the performance advantages of No-SQL without the housework. Just let nanoSQL know when and where you want your data and it takes care of the rest.
example code
Geolocation Helpers
Need to find which retail store your client is closest to? nanoSQL can do it in no time at all.
example code
Import / Export
It's easy to move CSV and JSON data into and out of nanoSQL.
example code
History (Undo / Redo)
NanoSQL can keep track of changes to your data so you can scrub back and forth through time.
example code
Live Backups
NanoSQL can optionally write to any number of database backends at the same time. This allows you to have always accurate, in place backups of your data.
example code
Events
Want to know when something is happening? Just ask!
example code
SQL Commands
Want to do a join with a group by and a query function? No problem!
example code
nanoSQL is an OPEN Open Source Project. This means that:
Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
Read more details here.
Copyright (c) 2018 Scott Lott
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.