advanced-storage-sdk
v1.0.3
Published
To install the `advanced-storage-sdk` package, run the following command:
Readme
Advanced Storage SDK Usage Guide
Installation
To install the advanced-storage-sdk package, run the following command:
npm install advanced-storage-sdkInitialization
Import and initialize the SDK in your JavaScript or TypeScript application, preferring a Singleton object to communicate with the super app:
import { AdvancedStorageSdk } from 'advanced-storage-sdk'; const advancedStorageSdk = new AdvancedStorageSdk();Detect the platform on which the super app is running for the mini app to function correctly:
let userAgent = advancedStorageSdk.detectPlatform(); advancedStorageSdk.setPlatformExecutor(userAgent);
Usage
Example Functions Using the SDK
- AdvancedStorage in the super app (This storage is constant and separate for each app and can be publicable):
let data = { type: AdvancedStorageDataType.DATABASE_RECORDS | AdvancedStorageDataType.DATABASE_COLLECTIONS, method: AdvancedStorageMethodType.CREATE_RECORD | AdvancedStorageMethodType.VIEW_RECORD | AdvancedStorageMethodType.LIST_RECORD | AdvancedStorageMethodType.LIST_FULL_RECORD | AdvancedStorageMethodType.UPDATE_RECORD | AdvancedStorageMethodType.DELETE_RECORD | AdvancedStorageMethodType.CREATE_COLLECTION | AdvancedStorageMethodType.VIEW_COLLECTION | AdvancedStorageMethodType.LIST_COLLECTION | AdvancedStorageMethodType.LIST_FULL_COLLECTION | AdvancedStorageMethodType.UPDATE_COLLECTION | AdvancedStorageMethodType.DELETE_COLLECTION, app_code: "", table_name: "", data: "", record_id: 0, expand: "", page: 1, per_page: 100, filter: "", sort: "" }; await advancedStorageSdk.advancedStorage(data) .then((res) => { console.log(res); }) .catch((e) => { console.log(e); });
Full Functions
For a complete list of available functions, refer to the following interface file that defines each request/response type:
/gap-miniapp-sdk/dist/interface/advanced_storage_interface