1.0.6 • Published 6 years ago

sqlite-orm-js v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

sqlite-orm-js

This is simple, javascript library for doing sqlite transactions with promises.

Uses

npm install sqlite-orm-js
    import SQLite from  'sqlite-orm-js';

or

    <script src="../node_modules/sqlite-orm-js/index.js"></script>

Methods

  • connect(name, version, description, size) - connection to local sqlite database

Example

    SQLite.connect('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
  • create(tableName , columnDef) - create table with column definitions

Example

    SQLite.create('pets', {
      'id': 'INTEGER PRIMARY KEY AUTOINCREMENT',
      'name': "TEXT"
    }).then(function(){
        console.log("OK");
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • destroy(tableName) - drop table

Example

    SQLite.destroy('pets')
  • add(tableName,dataDefe) - insert values into table

Example

    SQLite.add('pets',{
      'name': 'Chris'
    }).then(function(){
        console.log("ADD OK");
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • edit(tableName,dataDef, whereStatement) - update table with 'where' statement

Example

    SQLite.edit('pets',{
      'name': 'Christopher'
    },{
      'name': 'Chris'
    }).then(function(){
        console.log("EDIT OK");
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • find(tableName,whereStatement) - find rows with 'where' statemant

Example

    SQLite.find('pets',{
      'name': 'Christopher'
    }).then(function(result){
        console.log("FINDED:");
        console.log(result);
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • findAll(tableName) - find all rows in table

Example

    SQLite.findAll('pets').then(function(result){
        console.log("FINDED ALL:");
        console.log(result);
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • remove(tableName, whereStatement) - delete from table with 'where' statemant

Example

   SQLite.remove('pets',{
      'name': 'Chris'
    }).then(function(){
        console.log("REMOVE OK");
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
  • query(queryString) - execute own query

Example

    SQLite.query("SELECT * FROM pets").then(function(result){
        console.log("OK");
        console.log(result);
    }).catch(function(error){
        console.log("ERROR");
        console.log(error);
    });
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago