resource
resource.js REST resource CRUD utility
Author: harttleyangjun14@baidu.com
- resource
- Resource ⏏
- new Resource(url)
- .getUrl(options) ⇒
string
- .create(obj, options) ⇒
Promise
- .query(options) ⇒
Promise
- .update(obj, options) ⇒
Promise
- .delete(options) ⇒
Promise
- Resource ⏏
Resource ⏏
new Resource(url)
The REST resource CRUD utility
Param | Type | Description |
---|---|---|
url | string |
The RESTful url pattern |
resource.getUrl(options) ⇒ string
Get the URL for the given optionsions
Kind: instance method of Resource
Returns: string
- A string of URL.
Param | Type | Description |
---|---|---|
options | Object |
A set of key/value pairs to configure the URL query. |
resource.create(obj, options) ⇒ Promise
Create an Object from obj
with the given options
.
Kind: instance method of Resource
Returns: Promise
- A promise resolves when obj
is created successful,
and rejects whenever there is an error.
Param | Type | Description |
---|---|---|
obj | Object |
A plain Object to be created on the server. |
options | Object |
A set of key/value pairs to configure the URL query. |
resource.query(options) ⇒ Promise
Query Objects with the given options
.
Kind: instance method of Resource
Returns: Promise
- A promise resolves when retrieved successful,
and rejects whenever there is an error.
Param | Type | Description |
---|---|---|
options | Object |
A set of key/value pairs to configure the URL query. |
resource.update(obj, options) ⇒ Promise
Update the object specified by obj
with the given options
.
Kind: instance method of Resource
Returns: Promise
- A promise resolves when obj
is updated successful,
and rejects whenever there is an error.
Param | Type | Description |
---|---|---|
obj | Object |
A plain object to update with. |
options | Object |
A set of key/value pairs to configure the URL query. |
resource.delete(options) ⇒ Promise
Delete objects with the given options
.
Kind: instance method of Resource
Returns: Promise
- A promise resolves when obj
is deleted successful, and rejects whenever there is an error.
Param | Type | Description |
---|---|---|
options | Object |
A set of key/value pairs to configure the URL query. |