Skip to content

Commit

Permalink
features/update-documentations-and-release-version (#12)
Browse files Browse the repository at this point in the history
* Cleaned up

* Added getCollection and getAlias section

* Updated demo app

* Updated getAlias section

* Added ignore README.md

* Updated package.json
  • Loading branch information
michaeljymsgutierrez authored Jul 1, 2024
1 parent de689ac commit e112bd4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' })

<ul>
{addresses.map((address, index) => (
<li key={index}>{address.get('id')}</li>
))}
</ul>
```
#### Create record function
---
* **createRecord(collectionName, collectionRecord)**
Expand Down
9 changes: 9 additions & 0 deletions app/src/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -11,6 +15,11 @@ const App = observer(() => {

return (
<div className="App">
{/* <ul> */}
{/* {addresses.map((address, index) => ( */}
{/* <li key={index}>{address.get('id')}</li> */}
{/* ))} */}
{/* </ul> */}
{isLoading && <span>Loading...</span>}
{!isLoading && (
<div className="form">
Expand Down
1 change: 1 addition & 0 deletions packages/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Add all ignore files/directories here
node_modules
README.md
5 changes: 3 additions & 2 deletions packages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arm-js-library",
"version": "1.0.3",
"version": "1.0.4",
"description": "API Resource Manager",
"type": "module",
"files": [
Expand All @@ -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",
Expand Down
13 changes: 1 addition & 12 deletions packages/src/lib/api-resource-manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ARM JavaScript Library v1.0.0
* ARM JavaScript Library v1.0.4
*
* Date: 2024-05-09 2:19PM GMT+8
*/
Expand Down Expand Up @@ -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
*/

0 comments on commit e112bd4

Please sign in to comment.