New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

derpydb

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

derpydb

DerpyDB are useful database for create database with some collums, some tables and more amazing function for easier for your work, if you want contact me come to Discord: Derpy#6666

latest
Source
npmnpm
Version
0.3.7
Version published
Maintainers
2
Created
Source

DerpyDB

Basic code

const Database = require('derpydb');
// SQlite
const db = new Database({ uri: 'sqlite://db.sqlite' });
// MySQL
const db = new Database({ uri: 'mysql://user:pass@host/dbname' });

new Database([options])

  • options.uri: specific uri to connect (default: sqlite://db.sqlite).

Creates a new database connection.

const db = new Database({ uri: "sqlite://db.sqlite" });

.createTable([options])

Get the data from given id or id and target

  • options.table: specific table name to create (default: main).
db.createTable({ table: 'players' }); // true

.get(id, [options])

Get the data from given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be get (default: null).
// without target
const data = db.get('derpy', { table: 'info' }); // { name: "Derpy", age: 19 }
// with target
const data = db.get('derpy', { table: 'info', target: 'age' }); // 18
const data = db.get('derpy.age', { table: 'players' }); // 18

.set(id, value, [options])

set new data to given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be set (default: null).
db.set('derpy.age', 20, { table: 'info' }); // 20

.has(id, [options])

find if the given id is exits

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to find (default: null).
db.has('derpy.age', { table: 'info' }); // true

.type(id, [options])

find the type of the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to find type (default: null).
db.type('derpy.age', { table: 'info' }); // number

.startsWith(string, [options])

find the list datas that starts with the given string

  • options.table: specific table in the database (default: null).
db.startsWith('der', { table: 'info' }); // [{ id: 'derpy', value: { name: "Derpy", age: 19 }}]

.add(id, number, [options])

add number value to the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be added the number (default: null).
db.add('derpy.age', 1, { table: 'info' }); // 20

.remove(id, number, [options])

remove number value from the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be removed the number (default: null).
db.remove('derpy.age', 1, { table: 'info' }); // 18

.push(id, value, [options])

push new item value to the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be pushed in to (default: null).
db.get('derpy.list', { table: 'info' }); // ['banana', 'grape']
db.push('derpy.list', 'apple', { table: 'info' }); // ['banana', 'grape', 'apple']

.pull(id, value, [options])

pull item value from the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be pulled from it (default: null).
db.get('derpy.list', { table: 'info' }); // ['banana', 'grape', 'apple']
db.pull('derpy.list', 'grape', { table: 'info' }); // ['banana', 'apple']

.delete(id, [options])

delete value from the given id

  • options.table: specific table in the database (default: null).
  • options.target: specific a target to be deleted from it (default: null).
db.delete('derpy', { table: 'info' }); // true

.all([options])

get list of databases in specific table

  • options.table: specific table in the database (default: null).
db.all({ table: 'info' }); // [{ id: 'derpy', value: { name: 'Derpy', age: 19 }}]

.deleteAll([options])

delete all the databases from specific table

  • options.table: specific table in the database (default: null).
db.deleteAll({ table: 'info' }); // []

.tables()

get the list of the tables you created

db.tables(); // ['info']

.deleteTable([options])

delete specific table

  • options.table: specific table in the database (default: null).
db.deleteTable({ table: 'info' }); // true

.getTable([options])

get specific table information

  • options.table: specific table in the database (default: null).
db.getTable({ table: 'info' }); // { table: 'info', id: 'TEXT', value: 'TEXT' }

.db

run code through sqlite

db.db.prepare('SELECT * FROM info WHERE id = (?)').get('derpy') 

Keywords

sql

FAQs

Package last updated on 06 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts