Type definitions for DB transaction event has changed starting from V1.0.5
Use the jdb.IDBCoreEvent for type registry, see examples below.
Arguments
{string} DB_NAME (required)
{Number} DB_VERSION
Return
{object} jDB Instance
Usage
Details
Initialize isClient()
method to set the env to production. default: dev
Details
Initialize requiresLogin()
method to set the login flag for a database. default: false
Arguments
{object} definition
return: jDB Open Instance
onCreate(CB) createMode
Triggers when creating the DB for the first time.
onUpgrade(CB) createMode|upgradeMode
Triggers when creating the DB and also when DB upgrades.
onSuccess(CB)
JDB Promise instance
onError(CB)
JDB Promise instance
then(success, error)
JDB Promise instance
Details
Storage types: [localstorage, sessionstorage, memory] (in-built)
Other storage types are sql(sqlite, websql), indexedDB and flatfile which requires jdb adapter to perform.
Path to your schemaFolder.
Only set to true if you re using Frontendonly storage service.
live:{boolean} (default:false)
Set to true for autoSyncService to always sync client changes to server.
isClientMode:{boolean} (default:false)
Equivalent to isClient()
isLoginRequired:{boolean} (default:false)
Equivalent to isLoginRequired()
{String}
Define the URL of your server, by default is null
Don't have a server? Frontendonly is available for free.
Set to false to stop JDB from loading all configured API from the server.
Set to true to disable auto syncing or use array to list tables to disable.
Define Ajax method to be used within JDB for transporting data to server
This method is trigger before actuall call to server are made.
Define your organisation name, this is used within jdb-frontendonly
{Function}
This function is only initialized when there is a conflict between server and client records.
Only define a function if you don't want jdbSyncService to resolve the conflict.
{Function}
Define a function that can register all logs thrown from the syncService.
Define a function that will perform an action when sync is successfull
Define a function that will perform an action when sync fails.
Note : onCreate() is called when creating the database for the first time while onUpgrade() function is called when the version number of the DB changes.
This feature is introduced for managing database schemas and versioning.
Schema filename should be in this format "version_VERSION NUMBER" e.g version_1.json
These are operations accepted in a schema file: DROP | RENAME | ALTER | TRUNCATE | CREATE | CRUD(insert|update|delete|batch|insertreplace)
Below are examples of different operations that can be performed with schemaManager.
In CRUD Insert or Update operations, if filePath and data are defined filePath will be used instead of data, so choose which is best for your requirement.
Below are examples of different schema definition.
CREATE and CRUD operation are standalone and cannot be included with other operations.
returns the DB usage
returns the DB API key: {OBJECT}
This is available only when using JDB server (https://frontendonly.com).
returns all supported dataTypes in JDB
You can also remove or add custom dataTypes, but i bet you won't be needing this.
Arguments
{string} name (required)
{Array} schema
Schema Definition
{JDB_DATATYPES} type
required{boolean} AUTO_INCREMENT
(optional){string} ON_UPDATE
Allowed Types: DATE | CURRENT_TIMESTAMP | DATE_TIME | USER DEFINED (optional){string} defaultValue
Allowed Types: DATE | CURRENT_TIMESTAMP | DATE_TIME | USER DEFINED (optional){boolean} PRIMARY_KEY
(optional){boolean} NOT_NULL
introduced in v1.0.7-beta (optional)Return
jDB Promise Instance
Usage
Arguments
{string | ARRAY} TBL_NAME (required)
{string} MODE
Return
jDB Promise Instance
Usage
Drop column from current table
Types: [mode, key, index, column]
return {function} type instance
Instance
Types: [primary, foreign]
TableName: required only for adding foreign key
columnName: {string}
config: {Object}
columnName: {string}
settings: {Object}
mode: {string} [readonly, writeonly]
Arguments
{string} flag (YES | NO)
Details
Flag must be set to yes
to empty the table.
Note : NO flag will trigger an error. @DEFAULT : NO
Arguments
{string} flag (YES | NO)
Details
Flag must be set to yes
to empty the table.
Note : NO flag will trigger an error. @DEFAULT : NO
Arguments
{string | ARRAY} TBL_NAME (required)
{string} MODE
Return
{object} jDB Promise Instance
Arguments
{ARRAY} DATA (required)
{Boolean} hardInsert (optional)
introduced in v1.0.5-betaMode: write or writeonly
hardInsert parameter is used when importing a jQl file format.
Usage
lastInsertId()
Details:
Returns the last insert id of a table, usually this is determined if there's a column with AUTO_INCREMENT configuration.
Arguments
{ARRAY} DATA (required)
{String} columnName
Mode: write
Usage
Arguments
{OBJECT|STRING} DATA (required)
{OBJECT|STRING} Condition (optional)
If parameter is empty, all rows in table will be updated.
Mode: write or writeonly
Usage
Arguments
{OBJECT|STRING} condition
Mode: write or writeonly
Usage
Arguments
{String} fields (required)
{Object} queryDefinition (optional)
column types
*
To select all columnsCOUNT()
total result in a queryLOWERCASE(field)
convert field value to lowercaseUPPERCASE(field)
convert field value to uppercaseCURDATE()
return current date stringDATE_DIFF(field1, field2)
returns difference between 2 DATETIMESTAMP(FIELD)
converts DATETIME value to timestampCASE( WHEN COLUMN = CONDITION THEN COLUMN2 ELSE WHEN COLUMN2 = CONDITION THEN COLUMN ELSE NULL)
for field conditional statementGET(column)
return column_VALUECURDATETIME()
return current date and time stringMIN(column)
return minimum value in columnMAX(column)
return maximum value in columnSUM(column)
return sum of all value in columnAVG(column)
return average of all value in columnDIV(column_1:column_2)
return division of 2 column in a tableREVERSE(column)
return reverse string of a columnLENGTH(column)
return string length of a columnCONCAT(${column} ...)
return concatenated parameter, specify column using placeholder.RIGHT(column:length)
return substr from right.LEFT(column:length)
return substr from left.INSTR(column:needle)
return indexof of a needle in a column.TRIM(column)
return trimmed value of a columnSUBSTR(column:start:length)
return substring of a column by specifying the start position and lengthMode: read or readonly
Using Query Builder
eg : where(COLUMN = VALUE)
Please refer to JQL.select for more on string WHERE CLAUSE
eg: limit(0,10)
eg: groupBy(field)
eg: orderBy(fields:'ASC | DESC')
eg: groupByStrict(field)
jDBNumRows()
Details:
Returns number of row in result set
getRow(index)
Details:
Returns a row from result set by specifying the index of the row.
getResult()
Details:
Returns result set
first()
Details:
Returns first element in the result set.
openCursor(listener)
Details:
Iterate through the result set using cursor mode. Cursor event is passed as first parameter to the listener.
result
continue()
prev()
index()
limit(start, end)
Details:
Returns sets of elements in the result set by specifying the start and end index.
Arguments
{ARRAY} transactions (required)
transaction definition
{string} table
TableName{string} type
transaction types (insert|update|delete){Array} data
defined only in (insert|update) transactions.{string|object} query
defined only in (delete|update) transactions.Details:
Use this method to perform transactions on multiple tables. Failed validation on a single transaction will cause all transaction to also fail.
Arguments
{string} TBL_NAME
{object} definition
return: jDB Promise Instance
Details
Importing record opens a dialog box to select the file you want to import to the table, accepted files are (.csv,.jql,.html,.json)
Arguments
{string} FORMAT
return: export Instance
Details
Export a table record for referrence, accepted format are (.csv,.html,.json,.jql)
Task List
onSuccess
Function(CB)onError
Function(CB)then
Function(success, error)Arguments
{string} command (required)
{object} handlers
Details
jQL is the best feature of jEliDB, it have the ability to perform query using it's own query Syntax, it's easy to use, with or without SQL knowledge. Aside using JQL to perform query task, it can also be used for other actions like calling REST APIS provided by JELIDB Applications.
For more on JQL please click here
Create Custom jQL
Details
Get information about a database
Example Response:
Details
A stored procedure is a prepared jQl statement that you can save, so the code can be reused over and over again. You can also pass parameters to a stored procedure query, so that the stored procedure can act based on the parameter value(s) that is passed during execution state.
{boolean} flag (required)
Details
Close the database, this closes any open connection to the underlying storage and frees memory (event listeners) the database may be using.
Functionalities below can only work when serviceHost is set to true. Please refer to https://frontendonly.com for more details
return: Sync Instance
Details
Synchronize changes on the client to the server, jdbSyncService adapter will compare and check for changes between client and server. If the server is having the latest changes, the client will be updated with the server records else changes will be pushed to server for update
return: Sync Instance
Arguments:[ARRAYLIST] ARRAY_OF_TABLES optional
Details
Synchronize specific tables by defining them in the arguments, to sync complete DB set to null.
return: sync.processEntity || clientService Instance
Arguments: {OBJECT} Definition
Details:
This configurations can also be define when creating the database and it's extensible. Please look at Create a database
return: user Instance
Details
Protect your database by adding users and priviledges. It can also be used for login verification.
Arguments
{OBJECT} PARAM
Arguments
{OBJECT} PARAM
Arguments
{OBJECT} PARAM
Arguments
{OBJECT} PARAM
returns clientService Instance: {OBJECT}
{STRING}
required{OBJECT}
required{STRING}
required{OBJECT}
required{STRING}
required{OBJECT}
required{STRING}
required{OBJECT}
required{STRING}
required{OBJECT}
required{STRING}
required{OBJECT}
required