Universal database layer for the client, server & mobile devices. It's like Lego for databases.

Overview

Monorepo for nanoSQL 2.0

For 1.X releases, you can go here.

All links here send you to github source folders.

Packages

Adapters

Plugins

WIP

Items here are planned but not yet released.

Plugins

Query Support

Help

Documentation

Github Issues

Contributing

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.

MIT License

Copyright (c) 2019 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.

Comments
  • eventData.changedRows returning last obj in history on undo rather than history point

    eventData.changedRows returning last obj in history on undo rather than history point

    Question: Shouldn't eventData.changedRows[0] return the new state of any changed rows via the changed history point when undo/redo is triggered?

    I have an on("change") function set up that listens for changes to a table. I have an undoing and a redoing variable, the values of which are tied to undo and redo buttons.

    Note the 2 console.log's in my on("change") function. You can see that eventData.changedRows[0] always returns the latest point in history rather than the current history point after undo/redo.

    I'm getting around that right now by running a query to retrieve the changed row which does return the current history point so I'm able to get it to work. Just wondered if that was your intention for this.

    Below is a screenshot of the console.log's highlighted.

    (NOTE: Just as a FYI, .settings.activeSelectors.options[0] is the field I'm changing in order to test to keep my log's a little more simplified. In the first history point I assigned "testing one" as the value and in the next assigned "testing one two" )

    nSQL("aniblocks").on('change',function(eventData) {
    
      getHistory();
    
      switch(eventData.changeType) {
        case 'modified':
          if(eventData.changedRows.length > 0) {
    
            // eventData.changedRows[0] contains data from the latest history point
            console.log('row: ',eventData.changedRows[0].settings.activeSelectors.options[0]);
    
            if( undoing || redoing ) {
              db.query('select').where(['id','=', eventData.changedRows[0].id]).exec()
              .then(function(result,db){
    
                // result contains data from the current history point after an undo/redo
                console.log(result[0].settings.activeSelectors.options[0]);
               
                // doing stuff with it here
                animationsMgr.animateFromDB(result[0]);
                resetDoingVars();
              })
            }
          } else {
            // console.log('nothing changed');
          }
        break;
        case 'deleted':
          console.log('deleted');
        break;
        case 'inserted':
          console.log('inserted');
        break;
      }
    });
    
    screen shot 2017-05-10 at 7 06 53 am enhancement 
    opened by swampthang 21
  • SQL Error: too many SQL variables

    SQL Error: too many SQL variables

    Describe the bug When using a table with a primary key and secondary index, WebSQL queries fail to execute on large-ish datasets.

    SQLError {code: 5, message: "could not prepare statement (1 too many SQL variables)"}

    Example With a table consisting of 2 indexes and 7500 records, the following error occurs with the WebSQL adapater during the initial connect:

    _this._sql(false, "SELECT id FROM " + table, [], function (result) {

    Error: SELECT data from Vehicles WHERE id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,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?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (7483) [392430, 392437, 392441, 392442, 392443, 392446, 392449, 392450, 392451, 392455, 392533, 392537, 392539, 392540, 392546, 392555, 392556, 392558, 392561, 392566, 392572, 392574, 392576, 392581, 392582, 392583, 392584, 392585, 392597, 392598, 392605, 392609, 392620, 392631, 392643, 392647, 392656, 392657, 392659, 392660, 392662, 392663, 392668, 392669, 392670, 392671, 392672, 392683, 392690, 392697, 392700, 392710, 392713, 392716, 392718, 392724, 392727, 392734, 392743, 392755, 392762, 392766, 392767, 392771, 392789, 392793, 392797, 392816, 392820, 392821, 392822, 392831, 392834, 392842, 392843, 392847, 392851, 392852, 392854, 392858, 392859, 392861, 392862, 392863, 392872, 392936, 392939, 392942, 392948, 392949, 392952, 392956, 392960, 392961, 392969, 392974, 392976, 392979, 392983, 392987, …] SQLError {code: 5, message: "could not prepare statement (1 too many SQL variables)"}

    Expected behavior Expectation is for queries to execute correctly despite the data size and index count.

    bug 
    opened by MattNewberry 20
  • Really weird behaviour, perhaps caching?

    Really weird behaviour, perhaps caching?

    I'm using nanosql in my project to create a library that I then include into a different project.

    When I do the tests on my library everything works fine. But when I include it into the other project there's this really weird issue. The setup is as follows:

    • I use react-nanosql to react to onChange
    • I have a table TABLE with COLUMN with a single row
    • Within onChange I use a select query to get the new value
    • The COLUMN value in that row starts of with 0

    When I update the row, I can see a console.log showing that COLUMN has been changed to 1 The event passed into onChange is showing the same, with query.state being complete But the select within the onChange is showing the old value! It still shows 0!

    This is where it gets really weird. If the mode is set to TEMP everything works. If the mode is set to PERM, but I'm testing just my library everything works.

    The only time this doesn't work, is when I use the library within the other project, and the mode is PERM.

    This is very hairy.

    PS. The other project uses redux-persist with localforage

    bug 
    opened by plentylife 20
  • Remove leveldown dependency

    Remove leveldown dependency

    Would like to use nanosql with RocksDB, which is a successor of Leveldown. Wonder whether we could remove the leveldown dependency to further reduce package size.

    enhancement 
    opened by heri16 19
  • Can't connect database after upgrade to @nano-sql/core@2.3.2

    Can't connect database after upgrade to @nano-sql/[email protected]

    Which version are you using? from @nano-sql/[email protected] upgrade to @nano-sql/[email protected]

    Describe the bug Can't connect the exist database after upgraded, the nanoSql used in nodejs server, and use PERM mode store the data in file

    Example Today I wanna use the nanoSql new feature select('total'), and then upgrade the module, BUT occur the failure! I change the nSQL().connect to nSQL().createDatabase, also occur error!

    PS: I notice that it will run node-gyp to compile something when install the v2.2.3, but NOT when install the v2.3.2, Is new version missing some dependents against to the old version?

    bug 
    opened by grapewheel 16
  • undo/redo returning false

    undo/redo returning false

    Hi, Scott. I'm using the latest version. In an earlier version I had set up 2 buttons like this:

    $('#undo-btn').on("click", function(){
      nSQL().extend("<").then(function(response) {
        console.log(response) //<= If this is true, an undo action was done.  If false, nothing was done.
        if(response) {undoing = true};
      });
    })
    
    $('#redo-btn').on("click", function(){
      nSQL().extend(">").then(function(response) {
        console.log(response) //<= If this is true, a redo action was done.  If false, nothing was done.
        if(response) {redoing = true};
      });
    })
    

    These were working great prior to updating to the latest. I can confirm that changes have been made to rows in the (only) table in the database. This is logging the correct values on update...

    nSQL("aniblocks").on('change',function(eventData) {
      console.log('modified: ',eventData.changedRows);
    });
    

    I set a breakpoint on nSQL().extend("<").then(function(response) { and took some screenshots for you to peruse. screen shot 2017-05-02 at 12 55 13 pm

    screen shot 2017-05-02 at 12 55 37 pm screen shot 2017-05-02 at 12 56 21 pm screen shot 2017-05-02 at 12 56 51 pm screen shot 2017-05-02 at 12 57 24 pm screen shot 2017-05-02 at 1 00 01 pm screen shot 2017-05-02 at 1 00 23 pm bug 
    opened by swampthang 16
  • undo redo on change listener

    undo redo on change listener

    Should the change listener receive the the id of, or an object containing the record that was reset as a result of an undo or redo? Seems like that would be really great info to have. Currently I'm having to do this:

    An undo button listener:

    $('#undo-btn').on("click", function(){
      SomeSQL().extend("<").then(function(response) {
        if( response ) {
          resetOnStateChange();
        }
        console.log(response)
      });
      SomeSQL().extend("?").then(function(response) {
        console.log(response)
      });
    })
    

    The resetOnStateChange function snags all the records because I don't know what record to get:

      SomeSQL('aniblocks').getView('list_all_blocks')
      .then(function(result, db){
        console.log(result);
        // do stuff with the data
      });
    }
    

    I have a change listener like:

    SomeSQL("aniblocks").on('change',function(eventData) {
      console.log(eventData);
    })
    

    but it returns a set of empty arrays.. screen shot 2017-03-06 at 12 39 30 pm

    enhancement 
    opened by swampthang 16
  • Nested And / Or Statements Fail

    Nested And / Or Statements Fail

    Describe the bug When creating nested AND / OR statements for WHERE, the search fails.

    Example Works, but does not match my desired query:

    [
        ['account_id', '=', this.account.id],
        'AND', 
        ['name', 'LIKE', `%${this.searchQuery}%`]
    ]
    

    Does not work:

    [
        ['account_id', '=', this.account.id],
        'AND', 
        [
            ['name', 'LIKE', `%${this.searchQuery}%`]
        ]
    ]
    

    Does not work, but matches the final query desired:

    [
        ['account_id', '=', this.account.id],
        'AND', 
        [
      	['name', 'LIKE', `%${this.searchQuery}%`],
      	'OR',
      	['vin', 'LIKE', `%${this.searchQuery}%`]
        ]
    ]
    

    Expected behavior I would expect nested operators to correctly resolve themselves. For example, I would expect the final code example above to resolve to a similar SQL statement as:

    SELECT * FROM Vehicles WHERE account_id = 1 AND (name LIKE "%chevy%" OR vin LIKE "%chevy%")

    bug 
    opened by MattNewberry 14
  • Duplicate upsert

    Duplicate upsert

    when the following function gets called the result is an array containing 2 identical inserts.

    function addNewBlock(obj) {
      console.log('ran addNewBlock. obj: ',obj);
      nSQL('aniblocks')
      .doAction('add_new_block',{aniblock:obj}).then(function(result, db) {
        console.log(result);
        return db.getView('get_block_by_blockID',obj);
      }).then(function(result, db) {
        console.log('new block: ',result);
        return result;
      });
    }
    

    This is how nano-sql is being set up in that file:

    nSQL('aniblocks')
    .model([
      {key:'id',type:'uuid',props:['pk']},
      {key:'blockID', type: 'string', props: ["idx"]},
      {key:'blockInnerHTML', type: 'string'},
      {key:'foDom', type: 'string'},
      {key:'blockStartTime', type: 'float'},
      {key:'blockTimeScale', type: 'float'},
      {key:'title',type:'string'},
      {key:'type',type:'string'},
      {key:'settings',type:'map', default: null},
      // {key:'funcStr',type:'string', default: null},
      // {key:'removeSelector',type:'string', default: null},
      {key:'timelineData',type:'blob'}
    ])
    .actions([
      {
        name: 'add_new_block',
        args: ['aniblock:map'],
        call: function(args,db) {
          console.log('ran add_new_block. args: ',args);
          return db.query('upsert',args.aniblock).exec();
        }
      },
      {
        name: 'update_block',
        args: ['aniblock:map'],
        call: function(args,db) {
          var D = args.aniblock;
          // console.log(args.aniblock);
          return db.query('upsert',D).where(['blockID','=',D.blockID]).exec();
        }
      },
      {
        name: 'delete_block',
        args: ['aniblock:map'],
        call: function(args,db) {
          var D = args.aniblock;
          return db.query('delete',D).where(['blockID','=',D.blockID]).exec();
        }
      }
    ])
    .views([
      {
        name: 'get_block_by_blockID',
        args: ['blockID:string'],
        call: function(args,db) {
          console.log('ran get_block_by_blockID. args: ',args);
          return db.query('select').where(['blockID','=', args.blockID]).exec();
        }
      },
      {
        name: 'list_all_blocks',
        args: ['blockID:string'],
        call: function(args,db) {
          console.log('ran list_all_blocks');
          return db.query('select').exec();
        }
      }
    ])
    .on('error', function(eventData){
      console.log(eventData);
    })
    // .config({persistent:true})
    .connect().then(function(result,db){
      connected = true;
    });
    

    If I run list_all_blocks both of the items are returned. Any idea what I'm doing wrong?

    bug 
    opened by swampthang 13
  • new error related to leveldown

    new error related to leveldown

    Ran build in my Electron project and now getting this error:

    Uncaught Error: The module '/Users/username-was-here/Documents/project-name-was-here/build/node_modules/leveldown/build/Release/leveldown.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 48. This version of Node.js requires NODE_MODULE_VERSION 53. Please try re-compiling or re-installing the module (for instance, using npm rebuild ornpm install).

    This is the first time I'm seeing this.

    Using: node v6.9.5 npm version 3.10.10

    Went back to 0.4.5 and the error went away. Would love to up to a later version.

    help wanted 
    opened by swampthang 12
  • support for protocol buffers?

    support for protocol buffers?

    Hello this looks great, thanks very much. I'm using the levelDB setting - as I'd like to save a bunch of records via Node.js - then copy it all over to my server for read only access from my serverless single page javascript app.

    Look like I'll be able to do that nicely with this - but I'm also planning to use protocol buffers instead of json, as I have a lot of data - I've seen some other Node.js libraries that save to leveldb with this - and I think I can just decode/encode with yours - but have you thought of adding support for this?

    Thanks again.

    enhancement question 
    opened by mspanish 11
  • Selection of date types with undefined values

    Selection of date types with undefined values

    It is not possible to select values with type date, if the value is undefined.

    On selection the mutateRowTypes function is called. In this function columns with type date will be converter to ISOString on selection: new Date(useObj[m.key]).toISOString();

    If useObj[m.key] returns undefined, an error is thrown: RangeError: Invalid Date

    See: https://github.com/only-cliches/Nano-SQL/blob/af74705e3fc4be6e65c0e4044f7dc7c5b745886c/packages/Core/src/utilities.ts#L437

    Is there a reason why an ISODate is returned instead of Date type? I think there should be a conversion to ISODate on insert and a conversion to Date on select.

    If I'm wrong, please insert an undefined check before using new Date()

    Meanwhile I will try to use a "custom type" handling

                types: {
                    "date": {
                        onInsert: (colValue) => colValue ? new Date(colValue).toISOString() : undefined,
                        onSelect: (colValue) => colValue ? new Date(colValue) : undefined
                    }
                }
    

    (Btw: The interface describes onInsert and onSelect, but I cannot find any use of onInsert?)

    Im using nanosql with IndexedDB "@nano-sql/core": "^2.3.7",

    opened by murphy85 0
  • LOG file

    LOG file "backs up" every change to a row

    Which version are you using? ^2.3.7

    Describe the bug After any edits to a row in the database, it logs/backs up the entire row. For example, I have a "post" object that I want to add likes to. I do so, but it creates a whole new entry in "c1f7-5985"'s log file with the entire row. I only need to change it, not store another version. Nowhere have I stated that it should do this. This is also the same for other things like user data (separate tables).

    E.g. when spamming like/unlike, it adds to the file as such

    {"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,82445,391,2954716879�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1,2],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,82862,393,3960410894�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,83281,391,397385191�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1,2],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,83697,393,3445040025�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,84116,391,1107176446�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1,2],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,84533,393,4220412814�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,84952,391,4210006312�{"id":4,"text":"Well, how do YOU eat cheese?","creator":1,"created":1646029794133,"likes":[1,2],"repliesLastID":2,"replies":[{"id":0,"author":2,"text":"I like to eat cheese with my mouth, personally.","likes":[]},{"id":1,"author":1,"text":"I find that quite odd, past me.","likes":[1]},{"id":2,"author":2,"text":"I still agree with my statement about eating cheese with my mouth","likes":[]}]}:1,4,85369,393,569378032
    

    You see, that's way longer than it needs to be.

    Expected behavior For it to just update the row instead of back it up every time.

    opened by codingMASTER398 1
  • [Meta] Is this project still maintained?

    [Meta] Is this project still maintained?

    Just came across this project and it looks absolutely amazing! Works out of the box and beats many other libraries on benchmarks while also having extensive docs.

    I was wondering if this project is still maintained as I see the last push is from 2 years ago, or if there's any way I can get involved to keep it alive.

    opened by cuuupid 3
  • Can't query tables after restart, log parsing error

    Can't query tables after restart, log parsing error

    Which version are you using? version 2.3.7

    Describe the bug When using a freshly created DB, everything seems to work, but as soon as I kill node with Ctrl + C and restart the server, all queries for fetching data from tables results in the following error:

    C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:699
    
        throw new Error("Error parsing log file!");
        ^
    
    Error: Error parsing log file!
        at processLog_1 (C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:699:31)
        at ReadStream.<anonymous> (C:\repos\identity-hub\packages\implementation\node_modules\snap-db\bin\database.js:755:21)
    

    Expected behavior Queries against established tables with data that previously was present and queriable should remain so.

    Example I can get a copy of the repo up soon, but here are the relevant code sections: export default class Storage {

    
    export default class Storage {
    
      constructor(did, options = {}){
        this.did = did;
        this.dbName = did.split(':').slice(0, 3).join('-');
        this.ready = nano().createDatabase({
          id: this.dbName,
          mode: 'PERM',
          tables: this.tables = [
            {
              name: 'stack',
              model: {
                "id:string": { pk: true, immutable: true },
                "file:string": { immutable: true }
              }
            },
            {
              name: 'profile',
              model: {
                "id:string": { pk: true, immutable: true },
                "data:object": {},
                "signature:object": {}
              }
            },
            {
              name: 'permissions',
              model: {
                "id:string": { pk: true, immutable: true },
                "schema:string": { immutable: true, notNull: true },
                "data:object": { immutable: true },
                "signature:object": {}
              },
              indexes: {
                "schema:string": { ignore_case: true }
              }
            },
            {
              name: 'collections',
              model: {
                "id:string": { pk: true, immutable: true },
                "type:string": { immutable: true },
                "nonce:string": { immutable: true },
                "schema:string": { immutable: true, notNull: true },
                "root:string": { immutable: true },
                "parent:string": { immutable: true },
                "tags:array": {},
                "data:object": { immutable: true },
                "signature:object": {}
              },
              indexes: {
                "schema:string": { ignore_case: true }
              }
            },
            {
              name: 'actions',
              model: {
                "id:string": { pk: true, immutable: true },
                "nonce:string": { immutable: true },
                "schema:string": { immutable: true, notNull: true },
                "root:string": { immutable: true },
                "parent:string": { immutable: true },
                "data:object": { immutable: true },
                "signature:object": { immutable: true }
              },
              indexes: {
                "schema:string": {ignore_case: true}
              }
            }
          ]
        })  
      }
    
      async txn(fn){
        return this.ready.then(async () => {
          await nano().useDatabase(this.dbName);
          return fn(nano);
        });
      }
    
    }
    
    ClassInstance.txn(db => db('collections').query('select').exec()).catch(e => console.log(e));
    
    //  ^ this call fails
    
    opened by csuwildcat 1
  • nSQL: Can't do a query before the database is connected!

    nSQL: Can't do a query before the database is connected!

    Which version are you using? "@nano-sql/core": "^2.3.7" "snap-db": "^1.1.6"

    Describe the bug Query "select" throw exception

    Expected behavior Get data from specified table

    Example `const dbList = nSQL().listDatabases();

    console.log('dblist', dbList); //-> display one database : "organizer"

    nSQL().useDatabase("organizer");

    nSQL("watchings").query("select").exec().then((rows) => { console.log(rows) });`

    strange fact: upsert works well.

    opened by LearningProcesss 1
Releases(1.0.0)
  • 1.0.0(Dec 11, 2017)

    MANY BREAKING CHANGES, PLEASE READ THE MIGRATION GUIDE This build is intended to stabilize the library, increase performance and make it easy to extend in the future. The API for v1.X.X releases will be very stable moving forward.


    • Complete rewrite of the database engine, ORM system, and history system.
    • History can now be database wide (default), table wide or row wide.
    • Implimemented new plugin system with lifecycle events of every query.
    • The new built in storage engine uses the new plugin system, allowing you to remove/adjust how queries are handled.
    • Completely removed the old custom backend system and added a new adapter system.
    • You can no longer run the built in memory db with persistence.
    • All database adapters now use a sorted B-Tree index to gaurantee consistency.
    • You can use instance tables with nSQL queries. ex: nSQL([{name: "Bill"}, {name: "Bob"}]).query("select")....
    • History is no longer enabled by default.
    • Added WebSQL support. Safari in iOS/macOS will use WebSQL by default.
    • Added support for running IndexedDB in a webworker.
    • Added new INTERSECT and NOT INTERSECT .where() comparators. To check if any array values intersect with any values in an array of the database column.
    • .where() statements now accept a function, much like filter: nSQL("table").query("select").where(row => row.age > 20).exec()
    • Tables without a primary key are no longer supported, unless it's an instance table.
    • Added loadCSV method to automate importing CSVs into the database.
    • You can now get the version of NanoSQL being used with nSQL().version.
    • Database versions will now be tracked to make automatic migration changes in the future.
    • updateORM query has been removed entirely.
    • ORM updates now happen along side upsert, delete and drop queries.
    • ORM updates are more consistent and way more performant.
    • Added a large number of integration tests.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0r8(Dec 11, 2017)

  • 0.7.8(Apr 11, 2017)

Owner
Scott Lott
Husband, Programmer, Space Nerd, Builder of things.
Scott Lott
Cluster your Mongo databases just easy.

Mongster Now you can easily connect your nodes with Mongo DB into one cluster within the control panel. Imagine all of the options you get: Control Pa

MALL Group 6 Mar 15, 2022
That´s my to DO LIST , using VUE(3.0) , VUEX, VUE ROUTING, FIREBASE REALTIME DATABASE like BE, and WAVE UI

app Project setup npm install Compiles and hot-reloads for development npm run serve Compiles and minifies for production npm run build Lints and f

Steve 1 Jan 8, 2022
Nuxt client for genealogy project. Family tree and genealogy data processing website software client.

Family Tree 365 - Open Source Family Tree Software - Nuxt Client Description Browser based Genealogy software for interacting and processing data effi

Family Tree 365 100 Dec 14, 2022
Rest-api-client - Easily accessible REST API client available on your favorite browser

REST API Client Website: https://l23de.github.io/rest-api-client/ Inspirations t

Lester Huang 0 Jan 1, 2022
Mdmc-client - Song Client for https://mdmc.moe

mdmc-client To-Do Strengthening safety through ContextIsolation Finding and downloading charts using API from https://mdmc.moe/ Song Library Scanning

Amy Y 0 Jan 4, 2022
This repository contains a base networking framework for building a realtime quiz platform with Ably. This project uses VueJS on the client-side and NodeJS on the server-side and is scalable as you need.

A scalable, full-stack live quiz framework built with VueJS and NodeJS This repository contains a scalable framework for building a real-time quiz app

Ably Labs 47 Dec 14, 2022
Vue-client-recaptcha - Build simple recaptcha for vuejs without server need

vue-client-recaptcha Build simple recaptcha for vuejs without need server Depend

null 10 Nov 26, 2022
Torrust - a suite of client-server software for hosting online (private) torrent indexes

Torrust Project Description Torrust is a suite of client-server software for hosting online torrent indexes. Torrust only works with the torrust track

Torrust 99 Dec 20, 2022
Remote control Windows machine from anywhere powered by UltraVNC Server and Piping Server

piping-vnc-server-for-windows Remote control Windows machine from anywhere powered by UltraVNC Server and Piping Server How to use Suppose that Window

Ryo Ota 8 Dec 26, 2022
An easy to use new terminal for Windows/Linux/MacOS platform. It like Xshell or SecureCRT or PuTTY shell client.

NxShell An easy to use new terminal for Windows/Linux/MacOS platform. It like Xshell or SecureCRT or PuTTY shell client. NxShell Video Screenshots Mor

nxshell 706 Jan 3, 2023
A Twitter-like Nostr client made with Quasar

branle a twitter-like nostr client forked off from https://github.com/arcbtc/nos

fiatjaf 71 Jan 4, 2023
Simple universal resume based on Vue

Simple universal resume based on Vue

Rumyancev Alexander 18 Aug 15, 2022
Nuxt.js Universal App with SSR via Firebase Functions and Firebase Hosting

Nuxt.js Universal App with SSR via Firebase Functions and Firebase Hosting Host a Nuxt Universal app or site by combining Nuxt.js with Firebase Cloud

David Royer 282 Aug 20, 2022
A universal GUI for unit testing built with Electron and Vue.js

Lode Lode is an open source Electron-based universal test runner graphical user interface. It is written in TypeScript and Vue. Getting started You ca

Lode 91 Dec 9, 2022
Manage your android devices faster and easier !

Waterfal Project 是一个对新手友好的 Android 设备管理工具。 运行与构建 要运行 Waterfall Project ,您需要先安装 Nodejs 环境。 运行 npm install npm run electron:serve 构建 npm install npm ru

null 9 Jan 3, 2023
Desktop app for miners on the Helium network. Small taskbar tool to follow status, activity and earnings for the chosen devices.

Helium-Flick is a desktop application for Helium hotspot owners, in the shape of a small taskbar tool, which allows you to follow the status, activity and earnings for the devices of your list. The purpose of this application is to keep track of all your hotspots, directly at the corner of your screen.

Justine Vedovato 23 Jun 16, 2022
Simply Diary is an open source platform for an online diary, its really just a diary.

Simply Diary is an open source platform for an online diary, its really just a diary. Each diary has its own code, who knows the code also has access to the diary. Completely free and without registration.

cnry. 19 Oct 14, 2022
A vue component or component wrapper that makes an element movable and its movements can be customized.

v-movable A vue component or component wrapper that makes an element movable and its movements can be customized. Live Demo Installation npm i --save

Ron 20 Jul 9, 2022
Studying project - A Spring Boot API to store countries data in a MySQL DB, accompanied by its Vue.js app.

Screenshots See the screenshots here. Dependencies Java 11 Node.js <= 14 You can build locally and use the app without it, but it is meant to be used

Mao De Matos 0 Jan 17, 2022