gsql-connector
v0.0.2
Published
A g-sql connector to connect the g-sql data query language with an api in nodejs.
Downloads
3
Maintainers
Readme
G-SQL Connector
This is gsql connector, that helps to connect between g-sql and the nodejs projects.
G-sql is a structured database system that allows you to process data from tables, its the same query we used on other database systems. It only comes with extra advantages of the database system drawbacks.
How to use the connector:
The connector acceptes object paramter.
# To call/reference gsql-connector
const gconnector=require('gsql-connector').connection
# using paramters
gconnector.connect({
host:"192.168.2.2", # Or this can be a url where database available is, it can be other local network computer
space:"space1", # This is the space that contains the whole database system
user:"test_user", # User that has permission to login into the space of that host
password:"test_user", # Password is password of the user
port:"3001", # Port of the database where it found in the host
database:"test1" # This is optional field, it is a database name that found in the host/space/ and database name
})
gconnector.connect({
host:"https://www.yourwebsite.com",
space:"space1",
user:"test_user",
password:"test_user",
port:"3001",
database:"test1"
})
# using the connector to fetch data
gconnector.query('select * from test1.tb1',"",(error,row)=>{
console.log("rowww",row)
})
How to use inside function:
```sh
# using in a function syncron
function test(){
gconnector.query('select * from test1.tb1 where name=gide',"",(error,row)=>{
console.log("row",row)
})
}
# calling from function
test()
# using in a function async
function testAs(){
return new Promise((resolve,reject)=>{
gconnector.query('select * from test1.tb1 where name=gide',"",(error,row)=>{
console.log("row",row)
return resolve(row)
})
})
}
# calling asyn
async function mytest(){
let result = await testAs()
consol.log("result:",result)
# so result will come as an array like this
# result: [
# {
# message: '',
# success: true,
# data: [
# [Object], [Object]
# ]
# }
# ]
# message: is any text if there is action excuted or something not succeeded in the process
# success: is a boalean propertie which explains if the process was suceeded or not, if succeeded then it will be true otherwise false
# data: is any content of the respons of the result, it can hold object, array items, or it can be null as well
# So this shows that
# if you want a message then you could display the message like this result[0].message,
# if you want to know if the process was succeed or not then result[0].success, if true then it means the process was succeeded.
# if you want the data then result[0].data, so all content of the data will be displayed or can be manipulated.
}