Giter Club home page Giter Club logo

databaseapp's Introduction

DatabaseApp

A Simple, Local JSON-Based Database Application.


Contents


Installation

To install the package and create a database, run:

$npm install @aaryankh/dbapp

After installing, import the package into your project:

import Database from '@aaryankh/dbapp'

Getting started

The package provides many useful functions to work with local JSON-based databases.

To get started, create a new instance of the database app:

import Database from '@aaryankh/dbapp'
import path from 'path'

const db = new Database(path.join(__dirname, 'path-to-db-folder'))

You would need to specify the path to the folder where the database will be stored. (NOTE: It must be a folder 'path')


Creating a Collection

To create a new collection in the database, use the createCollection method:

db.createCollection('users', {
    name: 'string',
    age: 'number'
})

You must specify the name of the collection and the schema of the collection.


Inserting Data into Collection

To insert data into a collection, use the insert method:

db.insert('users', { name: 'John', age: 30 })

You must specify the name of the collection and the data to insert.


Finding Data in a Collection

To find data in a collection, use the find method:

db.find('users', { name: 'John' })

You must specify the name of the collection and the query to find the data.

This would return true if found and false if not found.


Fetching / Getting Data from a Collection

To get data from a collection, use the get method:

db.get('users', { name: 'John' })

You must specify the name of the collection and the query to get the data.

This would return the data array if found.


Find & Insert Data in a Collection

To find and insert data in a collection, use the findInsert method:

db.findInsert('users', { name: 'John' }, { name: 'Mike', age: 30 })

You must specify the name of the collection, the query to find the data, and the data to insert.


Find & Update Data in a Collection

To find and update data in a collection, use the findUpdate method:

db.findUpdate('users', { name: 'John' }, { name: 'Mike', age: 30 })

You must specify the name of the collection, the query to find the data, and the data to update.

You also have the option to upsert (only modify the specified fields) to update.

db.findUpdate('users', { name: 'John' }, { age: 30 }, true)
// This will only update the age field.

Find & Delete Data in a Collection

To find and delete data in a collection, use the findDelete method:

db.findDelete('users', { name: 'John' })

You must specify the name of the collection and the query to find the data.

Warning, this will delete all data that matches the query.


Deleting a Collection

To delete a collection, use the deleteCollection method:

db.deleteCollection('users')

You must specify the name of the collection to delete.

Warning, this will delete the whole collection.


Clearing Data in a Collection

To clear data in a collection, use the clear method:

db.clear('users')

You must specify the name of the collection to clear.

Warning, this will delete all data in the collection.


Future Features Plans

1. Counting Data in a Collection

2. GUI for Database App

3. More advanced queries

and much more...


Credits

Project Owner: AaryanKhClasses

Also Check My other Project: Sayout Clone


databaseapp's People

Contributors

aaryankhclasses avatar

Stargazers

 avatar

Watchers

 avatar

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.