GithubHelp home page GithubHelp logo

basemax / edb-sqlite-nodejs Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 33 KB

edb-sqlite: Easy Database SQLite NodeJs

License: MIT License

JavaScript 100.00%
nodejs js javascript sqlite sqlite-database sqlite3 sqlite3-database sqlite-orm sqlite-backend sqlite-nodejs

edb-sqlite-nodejs's Introduction

edb-sqlite-nodejs

Easy Database Sqlite Node-Js

For some small applications that use SQLite Database, I needed to design a small library to simplify my work. And connect to the database without any worries. So I also published the library that I implemented for the projects here.

Import edb-sqlite

const database = require(`./database`)

Using edb-sqlite

Open/Connect DB

database.open(`database.db`)

Create Table

database.run(`CREATE TABLE IF NOT EXISTS 'record'
(
    ID                      INTEGER PRIMARY KEY          NOT NULL,
    meetingId               CHAR(70)                     NOT NULL,
    recordId                CHAR(70)                     NOT NULL,
    status                  INTEGER                      NOT NULL
)`)

update

database.update(`UPDATE langs SET name = ? WHERE name = ?`, [`test`, `c`])

Delete

database.delete(`DELETE FROM langs WHERE rowid=?`, [1])

Insert

database.insert(`INSERT INTO langs(name) VALUES(?)`, [4])

Select(s) Rows

database.selects(`SELECT * FROM record WHERE status = 0 ORDER BY ID ASC LIMIT 5`, [],
(rows) => {
  console.log(rows)
  for(let row of rows) {
    console.log(row)
  }
})

Single Select

database.select(`SELECT * FROM record WHERE meetingId = ? AND recordId = ?`, [5, 8], (res) => {
  console.log(res)
})

Single Select Count

database.select(`SELECT COUNT(*) as count FROM record WHERE meetingId = ? AND recordId = ?`, [5, 8], (res) => {
  if(res[`count`]) {
    console.log(res[`count`])
  } else {
    console.log(`Error: ${res}`)
  }
})

Close/Disconnect db

database.close()

TODO EDB-Sqlite

  • Adding example js files
  • Publish package to npm package manager

I appreciate if anyone does these and send PR to me.


Max Base

My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers.

Asrez Team

A team includes some programmer, developer, designer, researcher(s) especially Max Base.

Asrez Team

edb-sqlite-nodejs's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

jowpurcinelli

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.