myscl-client
v0.1.5
Published
A simple client to connect to a MySCL database.
Downloads
22
Readme
MySCL Client
What is MySCL Client?
The MySCL Client is made for projects to be able to use the MySCL Server, refer to the server here.
This document lists all the possible functions, and even the simple caching capabilities.
Installation Process
Run the following command below in a new project to install the client.
npm i myscl-client
Database Documentation
createDB
The createDB function creates a database on the server, the function accepts a name that names the database.
function createDB(dbname)
Here is a basic implementation of the createDB function and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.createDB("website")
}
run()
createCollection
The createCollection function creates a subcategory in a database which is a collection. The function accepts arguments of the dbname that the collection is created in and the cname which is the name of the collection.
function createCollection(dbname, cname)
Here is a basic implementation of the createCollection function and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.createCollection("website", "collection")
}
run()
deleteDB
The deleteDB function simply deletes a database using the argument dbname. This function deletes a database if it exists.
function deleteDB(dbname)
Here is a basic implementation of the deleteDB function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.deleteDB("website")
}
run()
deleteCollection
The deleteCollection function deletes a collection in a database if it exists. The deleteCollection function accepts a argument of a dbname and cname.
function deleteCollection(dbname, cname)
Here is a basic implementation of the deleteCollection function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.deleteCollection("website", "collection")
}
run()
readAllDatabases
The readAllDatabases function returns an array of all the databases on the server. The command accepts no arguments.
function readAllDatabases()
Here is a basic implementation of the readAllDatabases function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
const databases = await db.readAllDatabases()
console.log(databases)
}
run()
readAllCollections
The readAllCollections function returns an array of all the collections in a given database. The function accepts an argument of a dbname.
function readAllCollections(dbname)
Here is a basic implementation of the readAllCollections function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
const collections = await db.readAllCollections("website")
console.log(collections)
}
run()
insertOne
The insertOne function inserts a object in a collection (document). The function accepts a few arguments including a dbname, cname, and a value of an object that is inserted into the collection.
function insertOne(dbname, cname, value)
Here is a basic implementation of the insertOne function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.insertOne("website", "collection", { name: "thing", random: 123 })
}
run()
insertMany
The insertMany function inserts multiple object in a collection (document). The function accepts a few arguments including a dbname, cname, and a value of an array with objects inside that is inserted into the collection.
function insertMany(dbname, cname, value)
Here is a basic implementation of the insertOne function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.insertMany("website", "collection", [
{ name: "thingy", random: 123 },
{ name: "thingy", random: 456 },
{ name: "asdf", random: 789 }
])
}
run()
findOne
The findOne function returns an object that is searched. It searches in a given collection in a database. The findOne arguments has arguments of a dbname, a cname, and a search object.
function findOne(dbname, cname, search)
Here is a basic implementation of the findOne function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
const search = await db.findOne("website", "collection", { name: "thingy" })
console.log(search) // { name: "thingy", random: 123 }
}
run()
findMany
The findMany function returns an array of objects depending on the search and collection It searches based off of a search object in a given collection in a database. The findMany functions has arguments of a dbname, a cname, and a search object.
function findMany(dbname, cname, search)
Here is a basic implementation of the findMany function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
const search = await db.findMany("website", "collection", { name: "thingy" })
console.log(search) // [ { name: "thingy", random: 123 }, { name: "thingy", random: 456 } ]
}
run()
deleteOne
The deleteOne function deletes only one object in a collection with a search object. The deleteOne function has arguments of a dbname, a cname, and a search object.
function deleteOne(dbname, cname, search)
Here is a basic implementation of the deleteOne function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.deleteOne("website", "collection", { random: 123 })
}
run()
deleteMany
The deleteMany function deletes many objects based on a search object in a given collection. The arguments that this function accepts are a dbname, a cname, and lastly a search object.
function deleteMany(dbname, cname, search)
Here is a basic implementation of the deleteMany function, and the implications. The basic implementation is listed below.
const { MySCL } = require("myscl-client")
const db = new MySCL("host", "port", "username", "password")
async function run() {
await db.deleteMany("website", "collection", { name: "thingy" })
}
run()
Caching Documentation
COMING SOON! COMING SOON! COMING SOON! COMING SOON! COMING SOON!