1.3.1 • Published 2 years ago
kiran-db v1.3.1
KIRAN-DB
It's implements how no-sql database works
install
npm i kiran-dbFile: dbs/User.js
const DB = require('kiran-db')
class User extends DB {
constructor (name) {
super(name)
}
}
module.exports = new User('users')
// Do the same thing to File: dbs/Post.jsFile: index.js
const User = require('./dbs/User')
const Post = require('./dbs/Post')WHERE
We can use where() to specified data to be selected
Model.where(data => data.id == 1).read()CREATE
We don't need to defined the id of each data. it will created automatically when db.create() runs
const singleuser = { username: 'kiran' }
const multipleposts = [
{ ownerid: 1, title: 'Lorem ipsum' },
{ ownerid: 1, title: 'Dolor sit amet' },
{ ownerid: 2, title: 'Consectetur adipiscing' },
]
const usercreated = User.create(singleuser)
const multipleposts = Post.create(multipleposts)
console.log({usercreated, multipleposts})READ
const users = User.read()
console.log({users})UPDATE
const newpostdata = {
ownerid: 1,
}
const updated = Post.where(post => post.id == 3).update(newpostdata)
console.log({updated})DELETE
const deleted = Post.where(post => post.id == 3).delete()
console.log({deleted})JOIN
const userposts = User.where(user => user.id = 1).join('posts', 'ownerid')
console.log({userposts})1.3.1
2 years ago
1.3.0
2 years ago
1.2.9
2 years ago
1.2.8
2 years ago
1.2.7
2 years ago
1.2.6
2 years ago
1.2.5
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.2.2
2 years ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.9
2 years ago
1.1.8
2 years ago
1.1.7
2 years ago
1.1.6
2 years ago
1.1.5
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago