db
SQLite database utilities
import "osl/db"Methods
db.open(path)→DBdb.openMemory()→DBdb.close()→errordb.exec(query, ...args)→booleandb.query(query, ...args)→arraydb.queryOne(query, ...args)→DBRowdb.queryMap(query, ...args)→arraydb.queryMapOne(query, ...args)→objectdb.insert(table, data)→numberdb.update(table, data, where, ...whereArgs)→booleandb.delete(table, where, ...whereArgs)→booleandb.count(table, where, ...whereArgs)→numberdb.exists(table, where, ...whereArgs)→booleandb.createTable(table, columns)→booleandb.dropTable(table)→booleandb.getTables()→arraydb.getColumns(table)→arraydb.begin()→booleandb.commit()→booleandb.rollback()→booleandb.transaction(fn)→errordb.lastInsertId()→numberdb.rowsAffected(query, ...args)→numberdb.collection(name)→dbCollectiondb.collections()→array
Returned object: DBRow
DBRowReturned by db methods; call these on the value you get back.
dBRow.get(colIndex)→anydBRow.getByName(colName)→anydBRow.toMap()→objectdBRow.toArray()→arraydBRow.isEmpty()→booleandBRow.count()→number
Returned object: dbCollection
dbCollectionReturned by db methods; call these on the value you get back.
dbCollection.insertOne(doc)→anydbCollection.insertMany(docs)→arraydbCollection.find(filter, ...opts)→arraydbCollection.findOne(filter)→objectdbCollection.findById(id)→objectdbCollection.all()→arraydbCollection.count(filter)→numberdbCollection.exists(filter)→booleandbCollection.updateOne(filter, changes)→numberdbCollection.updateMany(filter, changes)→numberdbCollection.replaceOne(filter, doc)→numberdbCollection.deleteOne(filter)→numberdbCollection.deleteMany(filter)→numberdbCollection.drop()→booleandbCollection.save(doc)dbCollection.query()→dbQuerydbCollection.where(field, op, value)→dbQuerydbCollection.fields(...cols)→dbQuerydbCollection.sort(field, dir)→dbQuery
Returned object: dbQuery
dbQueryReturned by db methods; call these on the value you get back.
dbQuery.where(field, op, value)→dbQuerydbQuery.and(field, op, value)→dbQuerydbQuery.sort(field, dir)→dbQuerydbQuery.fields(...cols)→dbQuerydbQuery.limit(n)→dbQuerydbQuery.skip(n)→dbQuerydbQuery.matched()→arraydbQuery.all()→arraydbQuery.get()→arraydbQuery.first()→objectdbQuery.count()→numberdbQuery.exists()→booleandbQuery.delete()→numberdbQuery.set(field, value)→dbQuerydbQuery.unset(field)→dbQuerydbQuery.inc(field, n)→dbQuerydbQuery.mul(field, n)→dbQuerydbQuery.min(field, value)→dbQuerydbQuery.max(field, value)→dbQuerydbQuery.push(field, value)→dbQuerydbQuery.pull(field, value)→dbQuerydbQuery.rename(field, newField)→dbQuerydbQuery.apply()→number
Complete API reference
db
dbdb.open(path: any)
*DB
Opens a resource.
db.openMemory()
*DB
Opens memory.
DB values
DB valuesMethods available on DB values returned by this package or constructed by the language.
value.close()
error
Closes the resource.
value.exec(query: any, ...args: any)
boolean
Runs the exec operation.
value.query(query: any, ...args: any)
array
Runs the query operation.
value.queryOne(query: any, ...args: any)
DBRow
Runs the query one operation.
value.queryMap(query: any, ...args: any)
array
Runs the query map operation.
value.queryMapOne(query: any, ...args: any)
object
Runs the query map one operation.
value.insert(table: any, data: object)
number
Runs the insert operation.
value.update(table: any, data: object, where: any, ...whereArgs: any)
boolean
Runs the update operation.
value.delete(table: any, where: any, ...whereArgs: any)
boolean
Deletes a value.
value.count(table: any, where: any, ...whereArgs: any)
number
Runs the count operation.
value.exists(table: any, where: any, ...whereArgs: any)
boolean
Reports whether the value or resource exists.
value.createTable(table: any, columns: object)
boolean
Creates table.
value.dropTable(table: any)
boolean
Runs the drop table operation.
value.getTables()
array
Returns tables.
value.getColumns(table: any)
array
Returns columns.
value.begin()
boolean
Runs the begin operation.
value.commit()
boolean
Runs the commit operation.
value.rollback()
boolean
Runs the rollback operation.
value.transaction(fn: any)
error
Runs the transaction operation.
value.lastInsertId()
number
Runs the last insert id operation.
value.rowsAffected(query: any, ...args: any)
number
Runs the rows affected operation.
value.collection(name: any)
*dbCollection
Runs the collection operation.
value.collections()
array
Runs the collections operation.
DBRow values
DBRow valuesMethods available on DBRow values returned by this package or constructed by the language.
value.get(colIndex: any)
any
Returns a value.
value.getByName(colName: any)
any
Returns by name.
value.toMap()
object
Converts the value to an object.
value.toArray()
array
Converts the value to an array.
value.isEmpty()
boolean
Reports whether empty.
value.count()
number
Runs the count operation.
dbCollection values
dbCollection valuesMethods available on dbCollection values returned by this package or constructed by the language.
value.insertOne(doc: object)
any
Runs the insert one operation.
value.insertMany(docs: array)
array
Runs the insert many operation.
value.find(filter: object, ...opts: object)
array
Runs the find operation.
value.findOne(filter: object)
object
Runs the find one operation.
value.findById(id: any)
object
Runs the find by id operation.
value.all()
array
Runs the all operation.
value.count(filter: object)
number
Runs the count operation.
value.exists(filter: object)
boolean
Reports whether the value or resource exists.
value.updateOne(filter: object, changes: object)
number
Runs the update one operation.
value.updateMany(filter: object, changes: object)
number
Runs the update many operation.
value.replaceOne(filter: object, doc: object)
number
Runs the replace one operation.
value.deleteOne(filter: object)
number
Deletes one.
value.deleteMany(filter: object)
number
Deletes many.
value.drop()
boolean
Runs the drop operation.
value.save(doc: object)
void
Runs the save operation.
value.query()
*dbQuery
Runs the query operation.
value.where(field: any, op: any, value: any)
*dbQuery
Runs the where operation.
value.fields(...cols: any)
*dbQuery
Runs the fields operation.
value.sort(field: any, dir: any)
*dbQuery
Runs the sort operation.
dbQuery values
dbQuery valuesMethods available on dbQuery values returned by this package or constructed by the language.
value.where(field: any, op: any, value: any)
*dbQuery
Runs the where operation.
value.and(field: any, op: any, value: any)
*dbQuery
Runs the and operation.
value.sort(field: any, dir: any)
*dbQuery
Runs the sort operation.
value.fields(...cols: any)
*dbQuery
Runs the fields operation.
value.limit(n: any)
*dbQuery
Runs the limit operation.
value.skip(n: any)
*dbQuery
Runs the skip operation.
value.matched()
array
Runs the matched operation.
value.all()
array
Runs the all operation.
value.get()
array
Returns a value.
value.first()
object
Runs the first operation.
value.count()
number
Runs the count operation.
value.exists()
boolean
Reports whether the value or resource exists.
value.delete()
number
Deletes a value.
value.addUpdate(kind: string, field: any, value: any)
*dbQuery
Adds update.
value.set(field: any, value: any)
*dbQuery
Sets a value.
value.unset(field: any)
*dbQuery
Runs the unset operation.
value.inc(field: any, n: any)
*dbQuery
Runs the inc operation.
value.mul(field: any, n: any)
*dbQuery
Runs the mul operation.
value.min(field: any, value: any)
*dbQuery
Runs the min operation.
value.max(field: any, value: any)
*dbQuery
Runs the max operation.
value.push(field: any, value: any)
*dbQuery
Runs the push operation.
value.pull(field: any, value: any)
*dbQuery
Runs the pull operation.
value.rename(field: any, newField: any)
*dbQuery
Runs the rename operation.
value.apply()
number
Runs the apply operation.
Notes
Standard-library imports accept both
import "osl/db"andimport "db".Return values such as
arrayandobjectare regular OSL values unless a returned object section says otherwise.
Last updated