0.0.6 • Published 2 years ago

upps v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Upps

Json databases it allows you to manage in an easy and detailed way.

Quick Start

Below we have assigned our module and the json file we will use.

const db = require('upps')
db.source = 'database.json'

/*  or another file
databases/database2.json , databases/mains/database1.json etc.
*/

Every time the source is changed, operations are made to the newly determined database source.

db.source = 'database1.json'
// some operations
db.source = 'database2.json'

.set(...more)

The set method is used to assign values ​​to keys. At least two parameters are given and the last parameter is always the value of the key. The key value can be a string, number, decimal number, or array. If the parameters are more than two, the key automatically takes the form of an object.

...
db.set('upps','monthly data','downloads',45)

/*  After this process, our database will look like this:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

.get(...more)

The get method is used to get values ​​of keys or objects.With more than one parameter, the values ​​of nested objects or the keys inside them can be retrieved. If the data is not in the database, the method returns undefined. And the note is printed to the console.

...
/*  Selected database source:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

data = db.get('upps')
console.log(data)

/* Prints to console
> { 'monthly data': { downloads: 45 } }
*/

data = db.get('upps','monthly data','downloads')
console.log(data)

/* Prints to console
> 45
*/

.delete(...more)

The delete method deletes data from database according to given parameters. If the data is not in the database, the method returns undefined. And the note is printed to the console.

...
/*  Selected database source:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

db.delete('upps')

/*  New version of the selected database resource:
{}
*/

db.delete('upps','monthly data','downloads')

/*  New version of the selected database resource:
{
 "upps": {
  "monthly data": {}
  }
}
*/

.has(...more)

The has method specifies whether the key in the given parameters exists or not. Returns true if yes, false if not.

/*  Selected database source:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

...
console.log(db.has('upps'))
console.log(db.has('upps','monthly data'))
console.log(db.has('ı<3u'))

/* Prints to console
> true
> true
> false
*/

.fetchAll()

The fetchAll method returns the entire selected database resource.

/*  Selected database source:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

...
allData = db.fetchAll()
console.log(allData)

/* Prints to console
> { upps: { 'monthly data': { downloads: 45 } } }
*/

.clearAll()

The clearAll method clears all data in the selected database resource.

/*  Selected database source:
{
 "upps": {
  "monthly data": {
   "downloads": 45
    }
  }
}
*/

db.clearAll()

/*  New version of the selected database resource:
{}
*/

Thanks for supporting me using my package.

I will bring new features and fixes to the package soon.

Contact me (discord): siaeyy#6434

Update Log :

  • The error in the readme.md has been fixed
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago