Content
Expression Extends:
class Content extends aggregate(ContentModel, Helper, Commentable)Helper class representing Content.
Constructor Summary
| Public Constructor | ||
| public | constructor(contentType: String | ContentType, json: Object, options: Object, meta: Object) Creates an instance of Content. | |
Member Summary
| Public Members | ||
| public | [key]: Any | |
| public set |  | |
| public get |  | |
| public set |  | |
| public get |  | |
| public get | Get objectType | |
| public set | Set the options used for API calls 
 | |
| public get |  | |
| public get |  | |
| public set |  | |
| public get |  | |
| public set |  | |
| public get | Get resource | |
| public set |  | |
| public get | Get status | |
| Private Members | ||
| private set | Set _data to set information to the current object. | |
| private get | _data: * Get _data to quickly get the raw data without options. | |
| private |  | |
| private |  | |
| private |  | |
| private |  | |
| private | _relationships: {} | |
| private |  | |
Method Summary
| Public Methods | ||
| public | Deletes a content | |
| public | Get the value of an attribute of the current content | |
| public | Get Status and set it to this._status | |
| public | Saves the current instance of Content | |
| public | Set the attribute of the current content | |
| public | async syncRelationships(json: *): Promise Synchronize the relationships from storage to the current object | |
Public Constructors
public constructor(contentType: String | ContentType, json: Object, options: Object, meta: Object) source
Creates an instance of Content.
Params:
| Name | Type | Attribute | Description | 
| contentType | String | ContentType | Content Type string | |
| json | Object | The data of the object for ContentModel | |
| json.id | Number | 
 | The ID of the content | 
| json.title | String | 
 | Title of the content | 
| json.description | String | 
 | A description related to the content | 
| json.created_at | String | 
 | The time at which the content was created | 
| json.updated_at | String | 
 | The time at which the content was updated | 
| json.position | Number | 
 | The platform position content is put | 
| json.tags | Array | 
 | The tags to describe the content | 
| json.brand | Object | 
 | The brand to describe the content | 
| options | Object | 
 | Options available to support the API. | 
| options.version | String | 
 | Version defaults to 'v2' | 
| options.owner_type | String | 
 | Owner Type defaults to 'mobile_user' | 
| meta | Object | 
 | Meta data supporting this item | 
Public Members
public [key]: Any source
public set contentType: ContentType source
public get contentType: ContentType source
public set options(options: Object): Object source
Set the options used for API calls
- owner (unique identifier / id)
- ownerType (content type)
- version
Private Members
private _relationships: {} source
Public Methods
public delete(): Promise source
Deletes a content
Example:
import { Content, Client } from 'clinical6';
// Removes content from server and local storage
const content = new Content({...});
content.delete();
// No longer in storage
Client.instance.storageUtility.has('contents', { id: 1 });public get(key: String): String | Number source
Get the value of an attribute of the current content
Params:
| Name | Type | Attribute | Description | 
| key | String | A String indicating the attribute key | 
Example:
myContent.get('title');public getStatus(): Promise<any> source
Get Status and set it to this._status
Example:
myContent.getStatus((status) => {
  console.log('status', status);
  console.log('status', myContent.status);
});public save(): Object source
Saves the current instance of Content
Example:
let car = new client.Content();
car.set('content_type', 'car');
car.set('title', 'My Car');
car.set('make', 'Toyota')
car.set('model', 'Corolla')
car.set('year', 2006)
// inserts
car.save().then(() => {
  // car now has id
  car.set('year', 2007);
  return car.save(); // car had id so this last save is an update
}); Manual
  Reference
  Source
  Test
  Manual
  Reference
  Source
  Test
   
    
  