SmartStore

open class SmartStore

Smart store Provides a secure means for SalesforceMobileSDK Container-based applications to store objects in a persistent and searchable manner. Similar in some ways to CouchDB, SmartStore stores documents as JSON values. SmartStore is inspired by the Apple Newton OS Soup/Store model. The main challenge here is how to effectively store documents with dynamic fields, and still allow indexing and searching.

Constructors

Link copied to clipboard
constructor(dbOpenHelper: SQLiteOpenHelper)
Relies on SQLiteOpenHelper for database handling.

Types

Link copied to clipboard
Enum for fts extensions
Link copied to clipboard
Exception thrown by smart store
Link copied to clipboard
enum Type
Enum for column type
Link copied to clipboard
Enum for type groups

Properties

Link copied to clipboard
val COLUMN_TYPE_COL: String = "columnType"
Link copied to clipboard
val FTS_SUFFIX: String = "_fts"
Link copied to clipboard
val PATH_COL: String = "path"
Link copied to clipboard
val SOUP_ATTRS_TABLE: String = "soup_attrs"
Link copied to clipboard
val SOUP_CREATED_DATE: String = "_soupCreatedDate"
Link copied to clipboard
val SOUP_ENTRY_ID: String = "_soupEntryId"
Link copied to clipboard
val SOUP_INDEX_MAP_TABLE: String = "soup_index_map"
Link copied to clipboard
val SOUP_LAST_MODIFIED_DATE: String = "_soupLastModifiedDate"
Link copied to clipboard
val SOUP_NAME_COL: String = "soupName"

Functions

Link copied to clipboard
open fun alterSoup(soupName: String, indexSpecs: Array<IndexSpec>, reIndexData: Boolean)
Alter soup using only soup name without extra soup features.
Link copied to clipboard
open fun beginTransaction()
Start transaction NB: to avoid deadlock, caller should have synchronized(store.
Link copied to clipboard
open fun changeKey(db: SQLiteDatabase, oldKey: String, newKey: String)
Changes the encryption key on the smartstore.
Link copied to clipboard
open fun clearSoup(soupName: String)
Clear all rows from a soup
Link copied to clipboard
open fun convertSmartSql(smartSql: String): String
Link copied to clipboard
open fun countQuery(querySpec: QuerySpec): Int
Link copied to clipboard
open fun create(soupName: String, soupElt: JSONObject): JSONObject
Create (and commits) Note: Passed soupElt is modified (last modified date and soup entry id fields)
open fun create(soupName: String, soupElt: JSONObject, handleTx: Boolean): JSONObject
Create Note: Passed soupElt is modified (last modified date and soup entry id fields)
Link copied to clipboard
open fun createLongOperationsStatusTable(db: SQLiteDatabase)
Create long_operations_status table
Link copied to clipboard
open fun createMetaTables(db: SQLiteDatabase)
Create soup index map table to keep track of soups' index specs Create soup name map table to keep track of soup name to table name mappings Called when the database is first created
Link copied to clipboard
open fun delete(soupName: String, soupEntryIds: Array<Long>)
Delete soup elements given by their ids (and commits)
open fun delete(soupName: String, soupEntryIds: Array<Long>, handleTx: Boolean)
Delete soup elements given by their ids
Link copied to clipboard
open fun deleteByQuery(soupName: String, querySpec: QuerySpec)
Delete soup elements selected by querySpec (and commits)
open fun deleteByQuery(soupName: String, querySpec: QuerySpec, handleTx: Boolean)
Delete soup elements selected by querySpec
Link copied to clipboard
open fun dropAllSoups()
Destroy all the soups in the smartstore
Link copied to clipboard
open fun dropSoup(soupName: String)
Destroy a soup Drop table for soupName Cleanup entries in soup index map table
Link copied to clipboard
open fun endTransaction()
End transaction (commit or rollback)
Link copied to clipboard
Link copied to clipboard
Get SQLCipher FIPS status
Link copied to clipboard
Get SQLCipher provider version
Link copied to clipboard
Get SQLCipher compile options
Link copied to clipboard
open fun getDatabase(): SQLiteDatabase
Return db
Link copied to clipboard
open fun getDatabaseSize(): Int
Get database size
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Get SQLCipher runtime settings
Link copied to clipboard
open fun getSoupIndexSpecs(soupName: String): Array<IndexSpec>
Return indexSpecs of soup
Link copied to clipboard
open fun getSoupTableName(soupId: Long): String
Link copied to clipboard
Get SQLCipher version
Link copied to clipboard
open fun hasIndexForPath(soupName: String, path: String): Boolean
Return true if the given path is indexed on the given soup
Link copied to clipboard
open fun hasSoup(soupName: String): Boolean
Check if soup exists
Link copied to clipboard
open fun lookupSoupEntryId(soupName: String, fieldPath: String, fieldValue: String): Long
Look for a soup element where fieldPath's value is fieldValue Return its soupEntryId Return -1 if not found Throw an exception if fieldName is not indexed Throw an exception if more than one soup element are found
Link copied to clipboard
open fun project(soup: JSONObject, path: String): Any
Link copied to clipboard
Same as project but returns JSONObject.
Link copied to clipboard
open fun query(querySpec: QuerySpec, pageIndex: Int): JSONArray
Run a query given by its query spec Returns results from selected page
Link copied to clipboard
open fun queryAsString(resultBuilder: StringBuilder, querySpec: QuerySpec, pageIndex: Int)
Run a query given by its query Spec Returns results from selected page without deserializing any JSON
Link copied to clipboard
open fun queryWithArgs(querySpec: QuerySpec, pageIndex: Int, whereArgs: Array<String>): JSONArray
Run a query given by its query spec with optional "where args" (i.e.
Link copied to clipboard
open fun registerSoup(soupName: String, indexSpecs: Array<IndexSpec>)
Register a soup.
Link copied to clipboard
open fun reIndexSoup(soupName: String, indexPaths: Array<String>, handleTx: Boolean)
Re-index all soup elements for passed indexPaths NB: only indexPath that have IndexSpec on them will be indexed
Link copied to clipboard
Finish long operations that were interrupted
Link copied to clipboard
open fun retrieve(soupName: String, soupEntryIds: Array<Long>): JSONArray
Retrieve
Link copied to clipboard
open fun setCaptureExplainQueryPlan(captureExplainQueryPlan: Boolean)
If turned on, explain query plan is run before executing a query and stored in lastExplainQueryPlan and also get logged
Link copied to clipboard
Sets the ftsX to be used when creating the virtual table to support full_text queries NB: only used in tests
Link copied to clipboard
open fun setLicenseKey(licenseKey: String)
Set license key for SQLCipher Needed when using commercial or enterprise editions of SQLCipher Should be called before using SmartStore
Link copied to clipboard
Mark transaction as successful (next call to endTransaction will be a commit)
Link copied to clipboard
open fun update(soupName: String, soupElt: JSONObject, soupEntryId: Long): JSONObject
Update (and commits) Note: Passed soupElt is modified (last modified date and soup entry id fields)
open fun update(soupName: String, soupElt: JSONObject, soupEntryId: Long, handleTx: Boolean): JSONObject
Update Note: Passed soupElt is modified (last modified date and soup entry id fields)
Link copied to clipboard
open fun updateTableNameAndAddColumns(db: SQLiteDatabase, oldName: String, newName: String, columns: Array<String>)
Updates the given table with a new name and adds columns if any.
Link copied to clipboard
open fun upsert(soupName: String, soupElt: JSONObject): JSONObject
Upsert (and commits) expecting _soupEntryId in soupElt for updates
open fun upsert(soupName: String, soupElt: JSONObject, externalIdPath: String): JSONObject
Upsert (and commits)
open fun upsert(soupName: String, soupElt: JSONObject, externalIdPath: String, handleTx: Boolean): JSONObject
Upsert