The jsql-sx javascript API allows you to interact with databases by using handles which are retrieved by invoking:
- jsql.DB.open(name, autosave)
You can then read/write to each specific database by using the handle's available methods.
jsql.DB.open(name, autosave)
Description
This class method will retrieve the handle (which is a 'jsql.DB' object) for interacting with the database identified by given name. If the DB does not yet exist, it will be created.
Parameters
- name: The name of the database to be opened.
- autosave: Optional flag (true or false) indicating whether this DB should be automatically saved whenever a change occurs. Defaults to true.
Returns
The 'jsql.DB' object handle for accessing the DB.
Example
// Open the database named 'book' //
var db = jsql.DB.open("book", false);
The code above will open a database named book with auto-saving disabled. If a database with the same name already exists in local storage, it will be loaded and become ready to be read/written. If not, a new one will be created.
Class Methods
The following [class methods] are available:
- jsql.DB.open(name, autosave)
- jsql.DB.supportsLS()
- jsql.DB.exists(name)
- jsql.DB.drop(name)
- jsql.DB.getDbNames()
Public Methods
The following [public methods] are available:
- jsql.DB.prototype.exists(table)
- jsql.DB.prototype.isEmpty(table)
- jsql.DB.prototype.create(name, definitions)
- jsql.DB.prototype.alter(table, operation, column, type, constraint)
- jsql.DB.prototype.insert(table, values)
- jsql.DB.prototype.select(table, sfields, condition)
- jsql.DB.prototype.update(table, set, condition)
- jsql.DB.prototype.delete(table, condition)
- jsql.DB.prototype.drop(table)
- jsql.DB.prototype.getTableNames()
- jsql.DB.prototype.getFieldNames(name)
- jsql.DB.prototype.load(name)
- jsql.DB.prototype.save(table)
- jsql.DB.prototype.setAutoSave(flag)
[Examples]
The wiki uses Markdown syntax.
Project Members: