Simple enabler for antarest and antarest-sql
v2.1.6:
- Npm audit fix
v2.1.5:
- Bug fix return create
v2.1.4:
- Create return object
v2.1.3:
- Fix typo index.d.ts
v2.1.2:
- Options to hard delete
v2.1.1:
- Bug fix delete function
v2.1.0:
- Return error Object
v2.0.0:
- All CRUD action will return array of T for consistency
- Add new type antarest-dynamo
v1.0.0:
- Initial release
Config object for initilaize:
config: {
baseUrl: 'http://your-baseUrl.com:1234',
url?: 'your-additional-url',
type: antarest,
isSQL: false // database model,
timeout?: 7777
}
Result Object:
{
status: 200,
msg: 'Ok'
payload: T
}
- create(objectType: T): Promise<AntarestResult>;
- get(options?: Comparator): Promise<AntarestResult<T[]>>;
- update(conditions: Comparator, patch: Patcher): Promise<AntarestResult<T[]>>;
- delete(conditions: Comparator, hardDelete?: boolean): Promise<AntarestResult<T[]>>;
- getById(id: number | string, identifier?: string): Promise<AntarestResult>;
- updateById(id: number | string, patch: object, identifier?: string): Promise<AntarestResult<T[]>>;
- deleteById(id: number | string, hardDelete?: boolean, identifier?: string): Promise<AntarestResult<T[]>>;
- query(query: object): Promise<AntarestResult<T[]>>; // for antarest-sql
- aggregate(aggregator: Comparator[]): Promise<AntarestResult<T[]>>; // for antarest
type Cat = {
name: string,
weight: number
}
class CatHome {
private _cat: AntarestService<Cat>
constructor(){
this._cat = new AntarestService<Cat>({
baseUrl: http://localhost:1234,
url: cat,
type: antarest,
isSQL: false,
timeout: 5000
})
}
public get Cat() {
return this._cat
}
}
const catHome: CatHome = new CatHome()
let tomPromise = catHome.Cat.get({
name: { $eq: Tom }
})
console.log(tomPromise)
// {
// status: 200,
// msg: 'OK',
// payload:
// [
// {
// name: Tom,
// weight: 200
// }
// ]
// }
let tom: Cat = tomPromise.payload[0]
console.log(tom)
// {
// name: Tom,
// weight: 200
// }