💾 Client Storage

By default, data stored in storage will be stored in a special collection, this is different from the database. Storage is divided into two types, local storage and global storage.
1. Local Storage
is storage that is limited to only working on certain browser tabs, which means that data stored in local storage can only be accessed and at home on certain tabs and other tabs in the browser cannot access this data
2. Global Storage
is unrestricted storage, all tabs in the same browser environment can access data stored in global storage. it is similar to CDatabase.

Data Transactions for Local Storage
 Add Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

CDatabase.addLocal('User', { name: 'Indra Jati', email: null });

 Update / Set Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

CDatabase.putLocal('User', 1, { name: 'Indra Jati', email: null });

 Get Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

const collectionData = await CDatabase.getLocal('User');

Data Transactions for Global Storage
 Add Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

CStorage.addGlobal('User', { name: 'Indra Jati', email: null });

 Update / Set Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

CDatabase.putGlobal('User', 1, { name: 'Indra Jati', email: null });

 Get Data

To add data to the database object, we can use the add command, as shown in the example below. To check whether the data has been successfully added, we can check IndexedDB in our browser's dev tools

const collectionData = await CDatabase.getGlobal('User');