@aravinthan_p/appnest-app-sdk-utils 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appnestFunctions/{appnestFunctions.MD → appnestBackendSdkFunctions.MD} +39 -34
- package/appnestFunctions/appnestClientFunctions.MD +98 -0
- package/appnestFunctions/dbFunction/db.MD +49 -46
- package/appnestFunctions/dbFunction/db.js +288 -40
- package/appnestFunctions/fileFunction/file.MD +19 -16
- package/appnestFunctions/fileFunction/file.js +45 -5
- package/appnestFunctions/httpFunction/http.MD +13 -11
- package/appnestFunctions/httpFunction/http.js +19 -1
- package/appnestFunctions/nextFunction/next.MD +6 -4
- package/appnestFunctions/nextFunction/next.js +12 -1
- package/appnestFunctions/scheduleFunction/schedule.MD +14 -12
- package/appnestFunctions/scheduleFunction/schedule.js +63 -7
- package/appnestFunctions/utils/apiConstants.js +2 -2
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# Appnest SDK Functions — Developer Reference
|
|
1
|
+
# Appnest Backend SDK Functions — Developer Reference
|
|
2
2
|
|
|
3
3
|
This document is the **single source of truth** for the Appnest custom SDK functions. Use it for **code generation**, auto-completion, and integration in your app.
|
|
4
4
|
|
|
5
|
-
**For code generation:** This file is self-contained
|
|
5
|
+
**For AI code generation:** (1) This file is self-contained; all function signatures, parameters, return shapes, and constraints are below. (2) **Import pattern:** The package exports `AppnestFunctions` and `ResultData` only. Always use: `const { AppnestFunctions } = require('@aravinthan_p/appnest-app-sdk-utils'); const { $db, $http, $file, $next, $schedule, getTraceId } = AppnestFunctions;` (destructure only the modules you need). Do not use `const { $db } = require('@aravinthan_p/appnest-app-sdk-utils')` — that is incorrect.
|
|
6
6
|
|
|
7
|
-
**Do not add `@aravinthan_p/appnest-app-sdk-utils` (or
|
|
7
|
+
**Do not add `@aravinthan_p/appnest-app-sdk-utils` (or `@aravinthan_p/appnest-app-sdk-utils`) to `app-backend/package.json`.** The SDK is provided by the AppNest platform at runtime. Your backend code should `require('@aravinthan_p/appnest-app-sdk-utils')` (or the package name configured by the platform) without listing it as a dependency.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
## Import
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
|
-
const { AppnestFunctions } = require('appnest-app-sdk-utils');
|
|
14
|
+
const { AppnestFunctions } = require('@aravinthan_p/appnest-app-sdk-utils');
|
|
15
15
|
// or from path:
|
|
16
16
|
// const { AppnestFunctions } = require('<path-to-sdk>/appnestFunctions');
|
|
17
17
|
|
|
@@ -33,23 +33,28 @@ const { $db, $file, $http, $next, $schedule, getTraceId } = AppnestFunctions;
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
-
## Module
|
|
36
|
+
## Module summary
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Brief overview of each module.
|
|
39
39
|
|
|
40
|
-
| Module
|
|
41
|
-
|
|
42
|
-
| **$db**
|
|
43
|
-
| **$http**
|
|
44
|
-
| **$file**
|
|
45
|
-
| **$next**
|
|
46
|
-
| **$schedule** |
|
|
40
|
+
| Module | Summary |
|
|
41
|
+
|-------------|--------|
|
|
42
|
+
| **$db** | Key/value by type: STRING, NUMBER, LIST, MAP, BOOLEAN. Common param: `key` (string). |
|
|
43
|
+
| **$http** | `$http.request({ url, method, headers, body, query })`. Methods: GET, POST, PUT, DELETE, PATCH. Use `<%=iparams.<key>%>` for manifest params; use `<%=user_oauth.access_token%>` in headers for platform access_token; framework replaces at runtime. |
|
|
44
|
+
| **$file** | `getUploadUrl`, `getDownloadUrl`, `delete`, `list`, `exists`. Params: `path`, `visibility` (optional). |
|
|
45
|
+
| **$next** | `$next.run({ functionName, payload, delay })`. Delay in seconds. |
|
|
46
|
+
| **$schedule** | Types: ONE_TIME, CRON, RECURRING. `name`, `type`, `data` required; type-specific: `runAt`, `cronExpression`, or `repeat`. |
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
50
|
## Code reference — function signatures & param details
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
**Return shapes (summary):**
|
|
53
|
+
- **$db:** Get methods return the value directly (string, number, array, object, boolean). Create/update/delete return nothing (`Promise<void>`).
|
|
54
|
+
- **$http:** `request` returns `Promise<{ headers, body, status }>`.
|
|
55
|
+
- **$file:** All methods return the response object directly (e.g. `{ preSignedUrl }`, `{ deleted }`, `{ objects }`, `{ exists }`). No `{ data, status }` wrapper.
|
|
56
|
+
- **$next:** `run` returns the API response body directly (e.g. `Promise<{ success: boolean }>`).
|
|
57
|
+
- **$schedule:** All methods return nothing (`Promise<void>`).
|
|
53
58
|
|
|
54
59
|
---
|
|
55
60
|
|
|
@@ -60,7 +65,7 @@ All functions return `Promise<{ data, status }>` unless noted.
|
|
|
60
65
|
| Function | Params | Types / constraints |
|
|
61
66
|
|----------|--------|----------------------|
|
|
62
67
|
| `$db.get({ key })` | key | string |
|
|
63
|
-
| `$db.create({ key })` | key | string |
|
|
68
|
+
| `$db.create({ key, value })` | key, value | key: string; value: string |
|
|
64
69
|
| `$db.update({ key, value })` | key, value | key: string; value: string |
|
|
65
70
|
| `$db.delete({ key })` | key | string |
|
|
66
71
|
| `$db.string.get({ key })` | key | string |
|
|
@@ -71,8 +76,8 @@ All functions return `Promise<{ data, status }>` unless noted.
|
|
|
71
76
|
| `$db.number.create({ key, value })` | key, value | key: string; value: number |
|
|
72
77
|
| `$db.number.update({ key, value })` | key, value | string, number |
|
|
73
78
|
| `$db.number.delete({ key })` | key | string |
|
|
74
|
-
| `$db.number.increment({ key })` | key | string |
|
|
75
|
-
| `$db.number.decrement({ key })` | key | string |
|
|
79
|
+
| `$db.number.increment({ key, value })` | key, value | key: string; value: number (optional, for increment amount) |
|
|
80
|
+
| `$db.number.decrement({ key, value })` | key, value | key: string; value: number (optional, for decrement amount) |
|
|
76
81
|
| `$db.list.get({ key })` | key | string |
|
|
77
82
|
| `$db.list.create({ key, value })` | key, value | key: string; value: array |
|
|
78
83
|
| `$db.list.update({ key, value })` | key, value | string, array |
|
|
@@ -95,39 +100,39 @@ All functions return `Promise<{ data, status }>` unless noted.
|
|
|
95
100
|
|
|
96
101
|
| Function | Params | Types / constraints |
|
|
97
102
|
|----------|--------|----------------------|
|
|
98
|
-
| `$http.request({ url, query, method, headers, body })` | url, query, method, headers, body | **url** (string, required)
|
|
103
|
+
| `$http.request({ url, query, method, headers, body })` | url, query, method, headers, body | **url** (string, required). **method** (string, required): `GET` \| `POST` \| `PUT` \| `DELETE` \| `PATCH`. **headers** / **body** / **query** (object, optional, default `{}`). **Return:** `Promise<{ headers, body, status }>`. **Runtime replacement:** Use `<%=iparams.<key>%>` and `<%=user_oauth.access_token%>` in headers. See [http.MD](httpFunction/http.MD). |
|
|
99
104
|
|
|
100
105
|
---
|
|
101
106
|
|
|
102
107
|
### $file
|
|
103
108
|
|
|
104
|
-
**Common params:** `path` (string, required), `visibility` (string, optional, default `"PUBLIC"`: `"PUBLIC"` \| `"PRIVATE"`).
|
|
109
|
+
**Common params:** `path` (string, required), `visibility` (string, optional, default `"PUBLIC"`: `"PUBLIC"` \| `"PRIVATE"`). All return the response object directly (no `{ data, status }` wrapper).
|
|
105
110
|
|
|
106
|
-
| Function | Params |
|
|
111
|
+
| Function | Params | Return |
|
|
107
112
|
|----------|--------|--------|
|
|
108
|
-
| `$file.getUploadUrl({ path, visibility })` | path, visibility |
|
|
109
|
-
| `$file.getDownloadUrl({ path, visibility })` | path, visibility |
|
|
110
|
-
| `$file.delete({ path, visibility })` | path, visibility |
|
|
111
|
-
| `$file.list({ path, visibility })` | path, visibility |
|
|
112
|
-
| `$file.exists({ path, visibility })` | path, visibility |
|
|
113
|
+
| `$file.getUploadUrl({ path, visibility })` | path, visibility | `Promise<{ preSignedUrl: string }>` |
|
|
114
|
+
| `$file.getDownloadUrl({ path, visibility })` | path, visibility | `Promise<{ preSignedUrl: string }>` |
|
|
115
|
+
| `$file.delete({ path, visibility })` | path, visibility | `Promise<{ deleted: boolean }>` |
|
|
116
|
+
| `$file.list({ path, visibility })` | path, visibility | `Promise<{ objects: Array<string> }>` |
|
|
117
|
+
| `$file.exists({ path, visibility })` | path, visibility | `Promise<{ exists: boolean }>` |
|
|
113
118
|
|
|
114
119
|
---
|
|
115
120
|
|
|
116
121
|
### $next
|
|
117
122
|
|
|
118
|
-
| Function | Params | Types / constraints |
|
|
119
|
-
|
|
120
|
-
| `$next.run({ functionName, payload, delay })` | functionName, payload, delay | **functionName** (string, required). **payload** (object, required). **delay** (number, optional, default 0): seconds
|
|
123
|
+
| Function | Params | Types / constraints | Return |
|
|
124
|
+
|----------|--------|----------------------|--------|
|
|
125
|
+
| `$next.run({ functionName, payload, delay })` | functionName, payload, delay | **functionName** (string, required). **payload** (object, required). **delay** (number, optional, default 0): seconds, >= 0. | `Promise<object>` (API response body, e.g. `{ success: boolean }`) |
|
|
121
126
|
|
|
122
127
|
---
|
|
123
128
|
|
|
124
129
|
### $schedule
|
|
125
130
|
|
|
126
|
-
**Common for create/update:** `name` (string, required, max 30), `type` (string, required: `ONE_TIME` \| `CRON` \| `RECURRING`), `data` (object, required, at least one key).
|
|
131
|
+
**Common for create/update:** `name` (string, required, max 30), `type` (string, required: `ONE_TIME` \| `CRON` \| `RECURRING`), `data` (object, required, at least one key). All schedule methods return `Promise<void>`.
|
|
127
132
|
|
|
128
133
|
| Function | Params | Types / constraints |
|
|
129
134
|
|----------|--------|----------------------|
|
|
130
|
-
| `$schedule.create({ name, type, data, runAt? \| cronExpression? \| repeat? })` | name, type, data + type-specific | **ONE_TIME:** `runAt` (string, required
|
|
135
|
+
| `$schedule.create({ name, type, data, runAt? \| cronExpression? \| repeat? })` | name, type, data + type-specific | **ONE_TIME:** `runAt` (string, required). **CRON:** `cronExpression` (string, required). **RECURRING:** `repeat: { frequency, timeUnit }` — frequency (integer >= 1; >= 10 if timeUnit is MINUTES), timeUnit: `MINUTES` \| `HOURS` \| `DAYS` \| `WEEKS` \| `MONTHS` \| `YEARS`. |
|
|
131
136
|
| `$schedule.get({ name, type })` | name, type | name: string; type: ONE_TIME \| CRON \| RECURRING |
|
|
132
137
|
| `$schedule.update({ name, type, data, runAt? \| cronExpression? \| repeat? })` | same as create | Same type-specific rules as create. |
|
|
133
138
|
| `$schedule.pause({ name, type })` | name, type | string, string |
|
|
@@ -149,15 +154,15 @@ All functions return `Promise<{ data, status }>` unless noted.
|
|
|
149
154
|
Typical pattern inside a Lambda or handler:
|
|
150
155
|
|
|
151
156
|
```javascript
|
|
152
|
-
const { AppnestFunctions } = require('appnest-app-sdk-utils');
|
|
157
|
+
const { AppnestFunctions } = require('@aravinthan_p/appnest-app-sdk-utils');
|
|
153
158
|
const { $db, $http, $file, $next, $schedule, getTraceId } = AppnestFunctions;
|
|
154
159
|
|
|
155
160
|
exports.myHandler = async (event, context) => {
|
|
156
161
|
const traceId = getTraceId();
|
|
157
162
|
// Use $db, $http, $file, $next, $schedule as needed
|
|
158
|
-
const row = await $db.string.get({ key: 'config' });
|
|
159
|
-
await $http.request({ url: 'https://api.example.com', method: 'GET', headers: {}, body: {}, query: {} });
|
|
160
|
-
await $next.run({ functionName: 'otherFn', payload: { id: 1 }, delay: 0 });
|
|
163
|
+
const row = await $db.string.get({ key: 'config' }); // row is the string value
|
|
164
|
+
const res = await $http.request({ url: 'https://api.example.com', method: 'GET', headers: {}, body: {}, query: {} }); // res === { headers, body, status }
|
|
165
|
+
const nextResult = await $next.run({ functionName: 'otherFn', payload: { id: 1 }, delay: 0 }); // nextResult is the API response body
|
|
161
166
|
};
|
|
162
167
|
```
|
|
163
168
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Appnest Client SDK — Invoke Backend Function
|
|
2
|
+
|
|
3
|
+
This document describes the **client-side** function used to invoke a backend (server) function by name. Use it for **code generation**, auto-completion, and integration in your app’s frontend or client code.
|
|
4
|
+
|
|
5
|
+
**For AI code generation:** This is the **client** API. Use `appBackendInvoke` when the client (e.g. browser, mobile app) needs to call a named backend function. For **backend** SDK functions (`$db`, `$http`, `$file`, `$next`, `$schedule`), see [appnestBackendSdkFunctions.MD](appnestBackendSdkFunctions.MD).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Import / usage
|
|
10
|
+
|
|
11
|
+
`appBackendInvoke` is provided by the Appnest client SDK. The exact import path depends on your project (e.g. from the platform’s client bundle or a local wrapper). Ensure `makeSparrowAppsApiRequest`, `createUUID`, `appId`, and `appVersionId` are available in scope (typically injected by the platform or your client setup).
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
// Example: after client SDK is loaded
|
|
15
|
+
const result = await appBackendInvoke({
|
|
16
|
+
apiFunctionName: 'myBackendHandler',
|
|
17
|
+
payload: { userId: 123, action: 'sync' }
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
### appBackendInvoke
|
|
26
|
+
|
|
27
|
+
Invokes a backend function by name. Sends a POST request to the platform’s backend-invoke endpoint with the given function name and payload. The client context (`appId`, `appVersionId`, `traceId`) is added automatically.
|
|
28
|
+
|
|
29
|
+
| Item | Description |
|
|
30
|
+
|------|--------------|
|
|
31
|
+
| **Signature** | `appBackendInvoke({ apiFunctionName, payload, options })` |
|
|
32
|
+
| **Return** | `Promise<any>` — the **parsed JSON body** of the backend response. Not `{ data, status }`; the response body is parsed and returned directly. |
|
|
33
|
+
| **Throws** | Rethrows if the request fails or response is not valid JSON. |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Parameters
|
|
38
|
+
|
|
39
|
+
| Parameter | Type | Required | Default | Description |
|
|
40
|
+
|-----------|------|----------|---------|-------------|
|
|
41
|
+
| `apiFunctionName` | string | yes | — | Name of the backend function to invoke (e.g. the server method/handler name). |
|
|
42
|
+
| `payload` | object | yes | — | Data to send to the backend function. Must be serializable (e.g. plain object, array). |
|
|
43
|
+
| `options` | object | no | `{}` | Optional extra options (reserved for future use). |
|
|
44
|
+
|
|
45
|
+
**Request:** The function sends a POST to `/v2/api/sparrow-apps/backend-invoke` with a body that includes `serverMethod` (same as `apiFunctionName`), `payload`, `appVersionId`, `appId`, and `traceId` (from `createUUID()`). The actual HTTP call is made via `makeSparrowAppsApiRequest`.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Return value
|
|
50
|
+
|
|
51
|
+
- **Success:** The **parsed JSON** of `response.body` is returned. Type is `any` (object, array, or primitive depending on what the backend returns).
|
|
52
|
+
- **Failure:** The promise rejects; errors are rethrown (e.g. network error, non-JSON response).
|
|
53
|
+
|
|
54
|
+
**Do not** assume a wrapper shape like `{ data, status }`. Use the returned value directly as the backend response body.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
**Invoke a backend function with a payload:**
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const data = await appBackendInvoke({
|
|
64
|
+
apiFunctionName: 'getUserSettings',
|
|
65
|
+
payload: { userId: 'user_123' }
|
|
66
|
+
});
|
|
67
|
+
// data is the parsed response body (e.g. { theme: 'dark', notifications: true })
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Invoke with empty payload:**
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
const result = await appBackendInvoke({
|
|
74
|
+
apiFunctionName: 'refreshCache',
|
|
75
|
+
payload: {}
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**With options (for future use):**
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const result = await appBackendInvoke({
|
|
83
|
+
apiFunctionName: 'exportData',
|
|
84
|
+
payload: { format: 'csv' },
|
|
85
|
+
options: {}
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Summary for code generation
|
|
92
|
+
|
|
93
|
+
| Function | Params | Return |
|
|
94
|
+
|----------|--------|--------|
|
|
95
|
+
| `appBackendInvoke({ apiFunctionName, payload, options })` | `apiFunctionName` (string, required), `payload` (object, required), `options` (object, optional, default `{}`) | `Promise<any>` — parsed JSON body of the backend response |
|
|
96
|
+
|
|
97
|
+
- **Client-only:** Use from frontend/client code to call backend functions by name.
|
|
98
|
+
- **Backend functions** (e.g. `getUserSettings`, `refreshCache`) are implemented on the server and documented in the backend SDK reference.
|
|
@@ -7,9 +7,11 @@ The `$db` module provides typed key/value storage operations. Use the namespaced
|
|
|
7
7
|
## Import / Usage
|
|
8
8
|
|
|
9
9
|
```javascript
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const { AppnestFunctions } = require('appnest-app-sdk-utils');
|
|
11
|
+
const { $db } = AppnestFunctions;
|
|
12
|
+
// or from path:
|
|
13
|
+
// const AppnestFunctions = require('<path-to-sdk>/appnestFunctions');
|
|
14
|
+
// const { $db } = AppnestFunctions;
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
---
|
|
@@ -20,7 +22,7 @@ const { $db } = require('appnest-app-sdk-utils');
|
|
|
20
22
|
|----------|--------|----------|--------------------------------------|
|
|
21
23
|
| `key` | string | yes | Non-empty, max 1000 characters |
|
|
22
24
|
|
|
23
|
-
**Return shape:**
|
|
25
|
+
**Return shape:** Get methods return the value directly (string, number, array, object, or boolean). Create, update, and delete methods return nothing (`Promise<void>`).
|
|
24
26
|
|
|
25
27
|
---
|
|
26
28
|
|
|
@@ -38,17 +40,18 @@ const { $db } = require('appnest-app-sdk-utils');
|
|
|
38
40
|
|
|
39
41
|
## Top-level (string-oriented)
|
|
40
42
|
|
|
41
|
-
| Method | Signature | Description |
|
|
42
|
-
|
|
43
|
-
| get | `$db.get({ key })` | Get value by key (string) |
|
|
44
|
-
| create | `$db.create({ key })` | Create key
|
|
45
|
-
| update | `$db.update({ key, value })` | Update string value |
|
|
46
|
-
| delete | `$db.delete({ key })` | Delete by key |
|
|
43
|
+
| Method | Signature | Description | Return |
|
|
44
|
+
|--------|-----------|-------------|--------|
|
|
45
|
+
| get | `$db.get({ key })` | Get value by key (string) | `Promise<string>` |
|
|
46
|
+
| create | `$db.create({ key, value })` | Create key with string value; for full control use `$db.string.create` | `Promise<void>` |
|
|
47
|
+
| update | `$db.update({ key, value })` | Update string value | `Promise<void>` |
|
|
48
|
+
| delete | `$db.delete({ key })` | Delete by key | `Promise<void>` |
|
|
47
49
|
|
|
48
50
|
**Example:**
|
|
49
51
|
|
|
50
52
|
```javascript
|
|
51
|
-
|
|
53
|
+
await $db.create({ key: 'welcome', value: 'hello' });
|
|
54
|
+
const result = await $db.get({ key: 'welcome' }); // result is the string value
|
|
52
55
|
await $db.update({ key: 'welcome', value: 'hello' });
|
|
53
56
|
await $db.delete({ key: 'welcome' });
|
|
54
57
|
```
|
|
@@ -57,12 +60,12 @@ await $db.delete({ key: 'welcome' });
|
|
|
57
60
|
|
|
58
61
|
## $db.string
|
|
59
62
|
|
|
60
|
-
| Method | Signature | Parameters |
|
|
61
|
-
|
|
62
|
-
| get | `$db.string.get({ key })` | `key` (string, required) |
|
|
63
|
-
| create | `$db.string.create({ key, value })` | `key`, `value` (string, required) |
|
|
64
|
-
| update | `$db.string.update({ key, value })` | `key`, `value` (string, required) |
|
|
65
|
-
| delete | `$db.string.delete({ key })` | `key` (string, required) |
|
|
63
|
+
| Method | Signature | Parameters | Return |
|
|
64
|
+
|--------|-----------|------------|--------|
|
|
65
|
+
| get | `$db.string.get({ key })` | `key` (string, required) | `Promise<string>` |
|
|
66
|
+
| create | `$db.string.create({ key, value })` | `key`, `value` (string, required) | `Promise<void>` |
|
|
67
|
+
| update | `$db.string.update({ key, value })` | `key`, `value` (string, required) | `Promise<void>` |
|
|
68
|
+
| delete | `$db.string.delete({ key })` | `key` (string, required) | `Promise<void>` |
|
|
66
69
|
|
|
67
70
|
**Example:**
|
|
68
71
|
|
|
@@ -77,14 +80,14 @@ await $db.string.delete({ key: 'welcome' });
|
|
|
77
80
|
|
|
78
81
|
## $db.number
|
|
79
82
|
|
|
80
|
-
| Method | Signature | Parameters |
|
|
81
|
-
|
|
82
|
-
| get | `$db.number.get({ key })` | `key` (string, required) |
|
|
83
|
-
| create | `$db.number.create({ key, value })` | `key`, `value` (number, required) |
|
|
84
|
-
| update | `$db.number.update({ key, value })` | `key`, `value` (number, required) |
|
|
85
|
-
| delete | `$db.number.delete({ key })` | `key` (string, required) |
|
|
86
|
-
| increment | `$db.number.increment({ key })` | `key` (string, required) |
|
|
87
|
-
| decrement | `$db.number.decrement({ key })` | `key` (string, required) |
|
|
83
|
+
| Method | Signature | Parameters | Return |
|
|
84
|
+
|-----------|-----------|------------|--------|
|
|
85
|
+
| get | `$db.number.get({ key })` | `key` (string, required) | `Promise<number>` |
|
|
86
|
+
| create | `$db.number.create({ key, value })` | `key`, `value` (number, required) | `Promise<void>` |
|
|
87
|
+
| update | `$db.number.update({ key, value })` | `key`, `value` (number, required) | `Promise<void>` |
|
|
88
|
+
| delete | `$db.number.delete({ key })` | `key` (string, required) | `Promise<void>` |
|
|
89
|
+
| increment | `$db.number.increment({ key, value })` | `key` (string, required), `value` (number, optional) | `Promise<void>` |
|
|
90
|
+
| decrement | `$db.number.decrement({ key, value })` | `key` (string, required), `value` (number, optional) | `Promise<void>` |
|
|
88
91
|
|
|
89
92
|
**Example:**
|
|
90
93
|
|
|
@@ -100,15 +103,15 @@ await $db.number.delete({ key: 'counter' });
|
|
|
100
103
|
|
|
101
104
|
## $db.list
|
|
102
105
|
|
|
103
|
-
| Method | Signature | Parameters |
|
|
104
|
-
|
|
105
|
-
| get | `$db.list.get({ key })` | `key` (string, required) |
|
|
106
|
-
| create | `$db.list.create({ key, value })` | `key`, `value` (array, required) |
|
|
107
|
-
| update | `$db.list.update({ key, value })` | `key`, `value` (array, required) |
|
|
108
|
-
| append | `$db.list.append({ key, value })` | `key`, `value` (array, required) |
|
|
109
|
-
| prepend | `$db.list.prepend({ key, value })` | `key`, `value` (array, required) |
|
|
110
|
-
| updateItemAtIndex | `$db.list.updateItemAtIndex({ key, value, index })` | `key`, `value` (array), `index` (number, required) |
|
|
111
|
-
| removeItemAtIndex | `$db.list.removeItemAtIndex({ key, index })` | `key`, `index` (number, required) |
|
|
106
|
+
| Method | Signature | Parameters | Return |
|
|
107
|
+
|-------------------|-----------|------------|--------|
|
|
108
|
+
| get | `$db.list.get({ key })` | `key` (string, required) | `Promise<array>` |
|
|
109
|
+
| create | `$db.list.create({ key, value })` | `key`, `value` (array, required) | `Promise<void>` |
|
|
110
|
+
| update | `$db.list.update({ key, value })` | `key`, `value` (array, required) | `Promise<void>` |
|
|
111
|
+
| append | `$db.list.append({ key, value })` | `key`, `value` (array, required) | `Promise<void>` |
|
|
112
|
+
| prepend | `$db.list.prepend({ key, value })` | `key`, `value` (array, required) | `Promise<void>` |
|
|
113
|
+
| updateItemAtIndex | `$db.list.updateItemAtIndex({ key, value, index })` | `key`, `value` (array), `index` (number, required) | `Promise<void>` |
|
|
114
|
+
| removeItemAtIndex | `$db.list.removeItemAtIndex({ key, index })` | `key`, `index` (number, required) | `Promise<void>` |
|
|
112
115
|
|
|
113
116
|
**Example:**
|
|
114
117
|
|
|
@@ -124,12 +127,12 @@ await $db.delete({ key: 'logs' });
|
|
|
124
127
|
|
|
125
128
|
## $db.map
|
|
126
129
|
|
|
127
|
-
| Method | Signature | Parameters |
|
|
128
|
-
|
|
129
|
-
| get | `$db.map.get({ key })` | `key` (string, required) |
|
|
130
|
-
| create | `$db.map.create({ key, value })` | `key`, `value` (object, required, JSON-serializable) |
|
|
131
|
-
| update | `$db.map.update({ key, value })` | `key`, `value` (object, required) |
|
|
132
|
-
| delete | `$db.map.delete({ key })` | `key` (string, required) |
|
|
130
|
+
| Method | Signature | Parameters | Return |
|
|
131
|
+
|--------|-----------|------------|--------|
|
|
132
|
+
| get | `$db.map.get({ key })` | `key` (string, required) | `Promise<object>` |
|
|
133
|
+
| create | `$db.map.create({ key, value })` | `key`, `value` (object, required, JSON-serializable) | `Promise<void>` |
|
|
134
|
+
| update | `$db.map.update({ key, value })` | `key`, `value` (object, required) | `Promise<void>` |
|
|
135
|
+
| delete | `$db.map.delete({ key })` | `key` (string, required) | `Promise<void>` |
|
|
133
136
|
|
|
134
137
|
**Example:**
|
|
135
138
|
|
|
@@ -144,12 +147,12 @@ await $db.map.delete({ key: 'profile' });
|
|
|
144
147
|
|
|
145
148
|
## $db.boolean
|
|
146
149
|
|
|
147
|
-
| Method | Signature | Parameters |
|
|
148
|
-
|
|
149
|
-
| get | `$db.boolean.get({ key })` | `key` (string, required) |
|
|
150
|
-
| create | `$db.boolean.create({ key, value })` | `key`, `value` (boolean, required) |
|
|
151
|
-
| update | `$db.boolean.update({ key, value })` | `key`, `value` (boolean, required) |
|
|
152
|
-
| delete | `$db.boolean.delete({ key })` | `key` (string, required) |
|
|
150
|
+
| Method | Signature | Parameters | Return |
|
|
151
|
+
|--------|-----------|------------|--------|
|
|
152
|
+
| get | `$db.boolean.get({ key })` | `key` (string, required) | `Promise<boolean>` |
|
|
153
|
+
| create | `$db.boolean.create({ key, value })` | `key`, `value` (boolean, required) | `Promise<void>` |
|
|
154
|
+
| update | `$db.boolean.update({ key, value })` | `key`, `value` (boolean, required) | `Promise<void>` |
|
|
155
|
+
| delete | `$db.boolean.delete({ key })` | `key` (string, required) | `Promise<void>` |
|
|
153
156
|
|
|
154
157
|
**Example:**
|
|
155
158
|
|