This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

quick.db-remote
TypeScript icon, indicating that this package has built-in type declarations

0.1.10 • Public • Published

Quick.db remote database

Adds the ability to create remote databases using quick.db.

WARNINNG

This tool is still under development, and it may have bugs. If you have any suggestion or found a bug, please DM me on discord: DarkenLight Mage#2401

Instalation

To install, just use

npm install quick.db-remote

If you find any error during instalation, feel free to contact me on Discord: DarkenLight Mage#2401

Changelog

Full ChangeLog: https://pastebin.com/mBfPp7wY

Latest:

## [0.1.9] - 2021-02-11

### Removed
Removed unwanted behaviour on fetch when requested entry does not exist.
Removed unnecessary and unwanted console logs.

Documentation

Documentation website: https://darkenlightmage.gitbook.io/quick-db-remote/

Single Connection Usage:

.login(domain, password)

This function sets up the connections to the servers you want to connect.

const db = require('quick.db-remote')
db.login(domain, password)

domain - The domain the server you are trying to connect is setted up. (Examples: https://your.website.com or https://your.website.com/database or https://your.website.com/your/custom/path or http:111.111.1.11:3000 or http:111.111.1.11:3000/your/custom/path) password - The password for the database.

BOTH MUST BE STRINGS

All the commands will follow this structure:

<key>
Where key is the database key you want to use.

Example:
db.fetch('key') //--> value

.fetch(key, [options])

This function returns data from a row based on the key. Alias: .get()

const db = require('quick.db-remote')
db.fetch('<key>')

.delete(key, [options])

This function deletes the specified key.

const db = require('quick.db-remote')
db.delete('<key>')

.push(key, value, [options])

This function will push into an array in the database based on the key. (If no existing array, it will create one)

const db = require('quick.db-remote')
db.push('<key>')

.add(key, number, [options])

This function adds a number to a key in the database. (If no existing number, it will add to 0)

const db = require('quick.db-remote')
db.add('<key>', value)

.subtract(key, number, [options])

This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)

const db = require('quick.db-remote')
db.subtract('<key>', value)

.all()

This function returns the entire active table as an array.

const db = require('quick.db-remote')
db.subtract('<key>')

.startsWith(key, [options])

This function returns all database keys that correspond to the key as an array

const db = require('quick.db-remote')
db.startsWith('<key>')

⚠️ WARNING: Due to the removal of this function from quick.db, it will only work in the versions <7.1.1 of quick.db.

new .table(name)

This function creates a new table, allowing you to separate your data while being used exactly the same. Use new to create a new table, do not use it if it already exists.

const db = require('quick.db-remote')
new db.table('<key>') // Creates table

db.table('<key>') // Accesses table

⚠️ This is a function that is yet being developed. It will may not work as intented.

Multiple Connection Usage

.login(connection file)

This function sets up the connections to the servers you want to connect.

const db = require('quick.db-remote')
db.login(connection_file)

connection_file: A Json file which contains all the connections and options for the database. There is a copy of that file in node_modules/quick-db-remote/test. It has the follow structure:

{
    "useLocalDB": false,
    "forceLoginRestart": true,
    "connections": {
        "main": {
            "domain": "",
            "password": ""
        }
    }
}^

useLocalDB - Defines if the package can use a db in your machine (IT USES YOUR COMPUTER FOR STORAGE, AND NOT THE REMOTE ONE). Default: false

forceLoginRestart - If enabled the package will restart the login cache automatically, making it usable without needing to restart. Default: true

connections - All the connections you want to set up. local and DEBUG are reserved names and cannot be used. (WARNING: I am not responsible for any harm that may occur to your machine if you change the package's code.)

All the commands will follow this structure:

<connection>::<key>
Where connection is one of the connections you've setted in your connections file, 
and key is the database key you want to use.

Example:
db.fetch('main::key') //--> value

.fetch(key, [options])

This function returns data from a row based on the key. Alias: .get()

const db = require('quick.db-remote')
db.fetch('<connection>::<key>')

.delete(key, [options])

This function deletes the specified key.

const db = require('quick.db-remote')
db.delete('<connection>::<key>')

.push(key, value, [options])

This function will push into an array in the database based on the key. (If no existing array, it will create one)

const db = require('quick.db-remote')
db.push('<connection>::<key>')

.add(key, number, [options])

This function adds a number to a key in the database. (If no existing number, it will add to 0)

const db = require('quick.db-remote')
db.add('<connection>::<key>', value)

.subtract(key, number, [options])

This function subtracts a number to a key in the database. (If no existing number, it will subtract from 0)

const db = require('quick.db-remote')
db.subtract('<connection>::<key>', value)

.all()

This function returns the entire active table as an array.

const db = require('quick.db-remote')
db.subtract('<connection>::<key>')

.startsWith(key, [options])

This function returns all database keys that correspond to the key as an array

const db = require('quick.db-remote')
db.startsWith('<connection>::<key>')

⚠️ WARNING: Due to the removal of this function from quick.db, it will only work in the versions <7.1.1 of quick.db.

new .table(name)

This function creates a new table, allowing you to separate your data while being used exactly the same. Use new to create a new table, do not use it if it already exists.

const db = require('quick.db-remote')
new db.table('<connection>::<key>') // Creates table

db.table('<connection>::<key>') // Accesses table

⚠️ This is a function that is yet being developed. It will may not work as intented.

Server Setup

To setup a server, use the function setupServer:

const db = require('quick.db-remote')
db.setupServer(port, password)

port - Port that the database server will listen to. password - Password that will be used to access the database The sintax above will open the server in http://your.ip:port. If you want the server to open the server in a specific url path, like for example http://your.ip:port/database, just use:

const db = require('quick.db-remote')
db.setupServer(urlpath, port, password)

urlpath - The path you want the database server to be initiated in. port - Port that the database server will listen to. password - Password that will be used to access the database.

FAQ

Q: I can't add the database to an url path on my website A: I added the express app the server uses to the global variable. To access it, simply use: app.use('/qdr', require(global.QDRappPath).app) And you will be able to access it using https://your.website/qdr/your/path/here

Readme

Keywords

Package Sidebar

Install

npm i quick.db-remote

Weekly Downloads

1

Version

0.1.10

License

MIT

Unpacked Size

66.3 kB

Total Files

22

Last publish

Collaborators

  • darkenlight_mage