1.3.1 • Published 1 year ago

kiran-db v1.3.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

KIRAN-DB

It's implements how no-sql database works

install

npm i kiran-db

File: 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.js

File: 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

1 year ago

1.3.0

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago