A plugin to acsess SQLite database in Sunbird Mobile app - available for the iOS and Android platforms.
cordova plugin add https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#<branch_name>
To install it locally
Clone the repo
cordova plugin add <location_of plugin>/sb-cordova-plugin-db
- db
- .init(dbName, dbVersion, migrations,successCallback)
- .open(filePath, successCallback)
- .close(isExternalDb, successCallback)
- .read(distinct,table,columns,selection,selectionArgs,groupBy,having,orderBy,limit, useExternalDb,successCallback, errorCallback)
- .execute(query,useExternalDb,successCallback, errorCallback)
- .insert(table, model,useExternalDb,successCallback, errorCallback)
- .update(table, whereClause, whereArgs, model,useExternalDb,successCallback, errorCallback)
- .delete(table, whereClause, whereArgs, useExternalDb,successCallback, errorCallback)
- .beginTransaction()
- .endTransaction(isOperationSuccessful,useExternalDb)
- .getDatabaseVersion()
- .bulkInsert(query, dataModels)
Initializes the database.
dbName
represents dbName.dbVersion
represents dbVersion.migrations
represents list of migrations to be executed.
Opens the database given in the filePath.
filePath
represents filePath of the database file.
Closes the database.
useExternalDb
represents whether the database is external or not.
db.read(distinct, table, columns, selection, selectionArgs,groupBy, having, orderBy,limit, useExternalDb, successCallback, errorCallback)
distinct
represents if you want each row to be unique, false otherwise..table
represents The table name to compile the query against.columns
represents a list of which columns to return. Passing null will return all columns, which is discouraged to prevent reading data from storage that isn't going to be used.selection
represents A filter declaring which rows to return, formatted as an SQL WHERE clause (excluding the WHERE itself). Passing null will return all rows for the given table.selectionArgs
You may include ?s in selection, which will be replaced by the values from selectionArgs, in order that they appear in the selection. The values will be bound as Strings.groupBy
represents a filter declaring how to group rows, formatted as an SQL GROUP BY clause (excluding the GROUP BY itself). Passing null will cause the rows to not be grouped..having
represents A filter declare which row groups to include in the cursor,if row grouping is being used, formatted as an SQL HAVING clause (excluding the HAVING itself). Passing null will cause all row groups to be included, and is required when row grouping is not being used.orderBy
represents How to order the rows, formatted as an SQL ORDER BY clause (excluding the ORDER BY itself). Passing null will use the default sort order, which may be unordered.limit
Limits the number of rows returned by the query, formatted as LIMIT clause. Passing null denotes no LIMIT clause.useExternalDb
represents whether the database is external or not.
Stops the scanner
query
represents the query to be executed.useExternalDb
represents whether the database is external or not.
Stops the scanner
table
represents the table to insert into.model
represents model to update in the table.useExternalDb
represents whether the database is external or not.
Stops the scanner
table
represents the table to update in.whereClause
represents the optional WHERE clause to apply when deleting. Passing null will delete all rows.whereArgs
represents arguments to be added in the whereClause.model
represents model to update in the table.useExternalDb
represents whether the database is external or not.
Stops the scanner
table
represents the table to delete from.whereClause
represents the optional WHERE clause to apply when deleting. Passing null will delete all rows.whereArgs
represents arguments to be added in the whereClause.useExternalDb
represents whether the database is external or not.
Begins a transaction in IMMEDIATE mode.
End a transaction
isOperationSuccessful
represents whether operation is succ.useExternalDb
represents whether the database is external or not.
Returns the database version.
Stops the scanner
query
represents toolbar title.dataModels
represents toolbar title.