diff --git a/README.md b/README.md index 3771df1..dd08ef4 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,25 @@ import { ARM } from 'path-to-src/index.js' ```javascript ARM.peekRecord('addresses', 123456) ``` +* **getCollection(collectionName)** + * Retrieving all records from collection. + ```javascript + ARM.getCollection('addresses') + ``` +* **getAlias(collectionName, collectionFallbackRecord)** + * Retrieving records from aliased request results. + * Support collectionFallbackRecord. - **optional** + ```javascript + const addresses = ARM.getAlias('customerAddresses', []) + + ARM.findAll('addresses', { alias: 'customerAddresses' }) + + + ``` #### Create record function --- * **createRecord(collectionName, collectionRecord)** diff --git a/app/src/page.js b/app/src/page.js index 4e5f952..4cc6930 100644 --- a/app/src/page.js +++ b/app/src/page.js @@ -2,6 +2,10 @@ import { observer } from 'mobx-react-lite' import { ARM } from './index.js' const App = observer(() => { + // const addresses = ARM.getAlias('customerAddresses', []) + // + // ARM.findAll('addresses', { alias: 'customerAddresses' }) + const { isLoading, data: address } = ARM.findRecord( 'addresses', 2461018, @@ -11,6 +15,11 @@ const App = observer(() => { return (
+ {/* */} {isLoading && Loading...} {!isLoading && (
diff --git a/packages/.gitignore b/packages/.gitignore index caa9716..47b2be3 100644 --- a/packages/.gitignore +++ b/packages/.gitignore @@ -1,2 +1,3 @@ # Add all ignore files/directories here node_modules +README.md diff --git a/packages/package.json b/packages/package.json index 7c5eccf..08f98eb 100644 --- a/packages/package.json +++ b/packages/package.json @@ -1,6 +1,6 @@ { "name": "arm-js-library", - "version": "1.0.3", + "version": "1.0.4", "description": "API Resource Manager", "type": "module", "files": [ @@ -16,7 +16,8 @@ }, "scripts": { "build:production": "vite build", - "build:watch": "vite build --watch" + "build:watch": "vite build --watch", + "publish": "cp ../README.md README.md && npm publish" }, "keywords": [ "arm", diff --git a/packages/src/lib/api-resource-manager.js b/packages/src/lib/api-resource-manager.js index 76f32c5..827984e 100644 --- a/packages/src/lib/api-resource-manager.js +++ b/packages/src/lib/api-resource-manager.js @@ -1,5 +1,5 @@ /* - * ARM JavaScript Library v1.0.0 + * ARM JavaScript Library v1.0.4 * * Date: 2024-05-09 2:19PM GMT+8 */ @@ -755,14 +755,3 @@ export default class ApiResourceManager { }) } } - -/* - * TO DO: Records new properties - * 1. isPristine - check if record is not modified - Done - * 2. isDirty - check if record is modified - Done - * 3. isLoading - check if record is doing ajax - Done - * 4. isError - check if record encountered an error - Done - * 5. rollBackAttributes - rollback record to is initial state - To Implement - * 6. reload - get latest record from server by id - Done - * 7. get by relationship like mapping - */