capacitor-sqlite-android
v0.2.0
Published
sqlite
Readme
capacitor-sqlite-android
sqlite
Install
npm install capacitor-sqlite-android
npx cap syncAPI
echo(...)loadDatabase(...)queryForObject(...)queryForList(...)insertEntity(...)updateEntity(...)delEntity(...)- Interfaces
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>测试方法
| Param | Type | Description |
| ------------- | ------------------------------- | ----------- |
| options | { value: string; } | echo params |
Returns: Promise<{ value: string; }>
loadDatabase(...)
loadDatabase(options: { dbPath?: string; dbName: string; }) => Promise<{ data: string | boolean; }>加载数据库
| Param | Type | Description |
| ------------- | ------------------------------------------------- | ----------------------------- |
| options | { dbPath?: string; dbName: string; } | dbPath: 数据库文件位置 dbName: 数据文件名 |
Returns: Promise<{ data: string | boolean; }>
queryForObject(...)
queryForObject(options: SQLiteQueryOptions) => Promise<{ data: any; }>查询单个对象
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- |
| options | SQLiteQueryOptions | 查询参数 {@link SQLiteQueryOptions} |
Returns: Promise<{ data: any; }>
queryForList(...)
queryForList(options: SQLiteQueryOptions) => Promise<{ data: any[]; }>查询列表
| Param | Type | Description |
| ------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- |
| options | SQLiteQueryOptions | 查询参数 {@link SQLiteQueryOptions} |
Returns: Promise<{ data: any[]; }>
insertEntity(...)
insertEntity(options: SQLiteEnitytOptions) => Promise<{ data: string | boolean; }>保存实体
| Param | Type | Description |
| ------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- |
| options | SQLiteEnitytOptions | 实体参数 {@link SQLiteEnitytOptions} |
Returns: Promise<{ data: string | boolean; }>
updateEntity(...)
updateEntity(options: SQLiteEntityUpdateOptions) => Promise<{ data: string | boolean; }>更新实体
| Param | Type | Description |
| ------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| options | SQLiteEntityUpdateOptions | 更新实体参数 {@link SQLiteEntityUpdateOptions} |
Returns: Promise<{ data: string | boolean; }>
delEntity(...)
delEntity(options: SQLiteEntityUpdateOptions) => Promise<{ data: string | boolean; }>删除实体
| Param | Type | Description |
| ------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| options | SQLiteEntityUpdateOptions | 更新实体参数 {@link SQLiteEntityUpdateOptions} |
Returns: Promise<{ data: string | boolean; }>
Interfaces
SQLiteQueryOptions
数据库查询对象
| Prop | Type | Description |
| ------------------- | --------------------- | ------------------------------- |
| tblName | string | 操作表名 |
| selection | string | 查询条件 eg: a=? and b like '%?' |
| selectionArgs | string[] | 查询的参数 替换 selection 中的 ? |
| returnColumns | string[] | 返回的列名 为空则返回所有 |
| groupBy | string | groupby 语句 eg: name |
| having | string | having 语句 eg: sum(area) > 20 |
| orderBy | string | order by 语句 eg: time desc |
| limit | number | limit 数量 eg: 10 |
SQLiteEnitytOptions
数据库实体保存对象
| Prop | Type | Description |
| ------------- | --------------------------------- | ------------------------------------------------------------------- |
| tblName | string | 操作的表名 |
| columns | SQLiteEntityColumn[] | 保存的数据列 {@link SQLiteEntityColumn} |
SQLiteEntityColumn
数据库实体数据列
| Prop | Type | Description |
| -------------- | ---------------------------------------- | ------------------ |
| name | string | 字段名称 |
| value | string | number | boolean | 字段值 |
| nullable | boolean | 是否允许为null 默认 false |
SQLiteEntityUpdateOptions
实体更新对象
| Prop | Type | Description |
| --------------------- | --------------------------------- | ------------------------------------------------------------------- |
| tblName | string | 操作的表名 |
| columns | SQLiteEntityColumn[] | 保存的数据列 {@link SQLiteEntityColumn} |
| whereClause | string | where 条件 eg: id=? |
| whereClauseArgs | string[] | where 条件参数 ? 的值 |
