Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Create a new ContentService. |
Member Summary
Public Members | ||
public |
The model of the service. |
|
public |
The maximum items to display per page. |
|
public |
Simple projection for showing multiple content items. |
|
public |
The query of the service. |
Method Summary
Public Methods | ||
public |
createContent(obj: Object): Promise<MongooseModel, Error> Insert the content into the database. |
|
public |
createMany(arr: Array<Object>): Promise<Array<MongooseModel>, Error> Insert multiple content models into the database. |
|
public |
deleteContent(id: string): Promise<MongooseModel, Error> Delete a content model. |
|
public |
deleteMany(arr: Array<Object>): Promise<Array<MongooseModel>, Error> Delete multiple content models from the database. |
|
public |
getContent(id: string, projection: Object): Promise<MongooseModel, Error> Get the content from the database with an id. |
|
public |
Get all the available pages. |
|
public |
Get content from one page. |
|
public |
Get random content. |
|
public |
updateContent(id: string, obj: Object): Promise<MongooseModel, Error> Update the content. |
|
public |
updateMany(arr: Array<Object>): Promise<Array<MongooseModel>, Error> Update multiple content models into the database. |
Public Constructors
public constructor(options: Object) source
Create a new ContentService.
Params:
Name | Type | Attribute | Description |
options | Object |
|
The options for the content service. |
options.Model | MongooseModel |
|
The model of the service. |
options.projection | Object |
|
The projection of the service. |
options.query | Object |
|
The query of the service. |
options.pageSize | number |
|
The page size of the service. |
Public Members
Public Methods
public createContent(obj: Object): Promise<MongooseModel, Error> source
Insert the content into the database.
Params:
Name | Type | Attribute | Description |
obj | Object |
|
The object to insert. |
public createMany(arr: Array<Object>): Promise<Array<MongooseModel>, Error> source
Insert multiple content models into the database.
public deleteContent(id: string): Promise<MongooseModel, Error> source
Delete a content model.
Params:
Name | Type | Attribute | Description |
id | string |
|
The id of the content to delete. |
public deleteMany(arr: Array<Object>): Promise<Array<MongooseModel>, Error> source
Delete multiple content models from the database.
public getContent(id: string, projection: Object): Promise<MongooseModel, Error> source
Get the content from the database with an id.
public getContents(base: string): Promise<Array<string>, Error> source
Get all the available pages.
Params:
Name | Type | Attribute | Description |
base | string |
|
The base of the url to display. |
public getPage(sort: Object, p: number, query: Object): Promise<Array<MongooseModel>, Error> source
Get content from one page.
public updateContent(id: string, obj: Object): Promise<MongooseModel, Error> source
Update the content.