API Docs for: 0.8.0
Show:

PageService Class

Provides functions to interact with pages

Constructor

PageService

(
  • context
)

Parameters:

  • context Object
    • [contentSettings] Object optional
    • site String
    • onlyThisSite Boolean

Methods

_emit

(
  • event
  • data
  • cb
)
protected

Parameters:

  • event String
  • data Object
  • cb Function

_get

(
  • id
  • [options]
  • cb
)
protected

Parameters:

  • id String
  • [options] Object optional
  • cb Function

_retrieveOnUpdateAndMerge

(
  • dto
  • options
  • cb
)
private
When an ID is available in the DTO the function attempts to retrieve the existing object. If it is not available a new object is created. The merge event is then called. After the merge is complete the callback is executed with the merged object.

Parameters:

  • dto Object
  • options Object
    • [isCreate] Boolean optional
  • cb Function

add

(
  • dto
  • [options]
  • cb
)
Attempts to persist the DTO as an add. The function executes a series of events: 1) The format event is fired 2) When an ID is provided the object is retrieved from the database otherwise a new object is created. 3) The merge event is triggered 4) The validate event is triggered. If validation errors are detected the process halts and the function calls back with an error. 5) The beforeSave event is triggered 6) The object is persisted 7) The afterSave event is triggered

Parameters:

  • dto Object
  • [options] Object optional
  • cb Function
    A callback that takes two parameters. The first is an error, if occurred. The second is the object that matches the specified query

count

(
  • [options]
  • cb
)
Executes a count of resources against the persistence layer. The function will callback with an array of results.

Parameters:

  • [options] Object optional
    • [where] Object optional
  • cb Function
    A callback that takes two parameters. The first is an error, if occurred. The second is the number of results that match the specified query

deleteById

(
  • id
  • options
  • cb
)
Deletes an object by ID

Parameters:

  • id String
  • options Object
  • cb Function

deleteSingle

(
  • [options]
  • cb
)
Deletes a single item based on the specified query in the options

Parameters:

  • [options] Object optional
    See BaseObjectService#getSingle
    • [where] Object optional
  • cb Function

format

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • service PageService

      An instance of the service that triggered the event that called this handler

    • data Object
  • cb Function

    A callback that takes a single parameter: an error if occurred

gatherDataForRender

(
  • contentArray
  • cb
)

Parameters:

  • contentArray Array
  • cb Function

get

(
  • id
  • options
  • cb
)

Parameters:

  • id String
  • options Object
    • [render=false] Boolean optional
    • [readMore=false] Boolean optional
  • cb Function

getAll

(
  • [options]
  • cb
)

Parameters:

  • [options] Object optional
    • [where] Object optional
    • [select] Object optional
    • [order] Array optional
    • [limit] Integer optional
    • [offset] Integer optional
    • [render=false] Boolean optional
    • [readMore=true] Boolean optional
  • cb Function

getAllWithCount

(
  • [options]
  • cb
)
Executes a query for resources against the persistence layer. The function will callback with an object that contains a total count and an array of results. The function will trigger the "getAll" event. Also note that there is hard limit on the number of results the returned.

Parameters:

  • [options] Object optional
    • [select] Object optional
    • [where] Object optional
    • [order] Array optional
    • [limit] Integer optional
    • [offset] Integer optional
  • cb Function
    A callback that takes two parameters. The first is an error, if occurred. The second is an object representing the results of the query.

getContext

(
  • [data]
)
Object
Retrieves a context object to be passed to event listeners

Parameters:

  • [data] String | Object | Number | Boolean optional

Returns:

Object:

getDrafts

(
  • [options]
  • cb
)

Parameters:

  • [options] Object optional
    • [where] Object optional
    • [select] Object optional
    • [order] Array optional
    • [limit] Integer optional
    • [offset] Integer optional
    • [render=false] Boolean optional
  • cb Function

getIdWhere

(
  • dto
)
Object
Creates the where clause that creates a lookup by the key that indicates uniqueness for the collection

Parameters:

  • dto Object

Returns:

Object:

getMetaInfo

(
  • content
  • cb
)

Retrieves the SEO metadata for the specified content.

Parameters:

  • content Object

    The content to retrieve information for

  • cb Function

    A callback that takes two parameters. The first is an Error, if occurred. The second is an object that contains 4 properties: title - the SEO title, description - the SEO description, keywords - an array of SEO keywords that describe the content, thumbnail - a URI path to the thumbnail image

getPublished

(
  • [options]
  • cb
)

Parameters:

  • [options] Object optional
    • [where] Object optional
    • [select] Object optional
    • [order] Array optional
    • [limit] Integer optional
    • [offset] Integer optional
    • [render] Boolean optional
  • cb Function

getRenderer

() PageRenderer

Retrieves an instance of a content renderer

Returns:

getRenderOptions

(
  • options
  • isMultiple
)
Object

Provides the options for rendering

Parameters:

  • options Object
  • isMultiple Boolean

Returns:

Object:

getSingle

(
  • [options]
  • cb
)

Parameters:

  • [options] Object optional
    • [select] Object optional
    • [where] Object optional
    • [order] Array optional
    • [offset] Integer optional
    • [readMore=false] Boolean optional
  • cb Function

getTopicsForContent

(
  • content
)
Array

Extracts an array of Topic IDs from the content that the content is associated with.

Parameters:

  • content Object

Returns:

Array:

An array of strings representing the Topic IDs

getType

() String
Retrieves the object type supported by the service

Returns:

String: The object type supported

merge

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • service PageService

      An instance of the service that triggered the event that called this handler

    • data Object
  • cb Function

    A callback that takes a single parameter: an error if occurred

render

(
  • contentArray
  • [options]
  • cb
)

Parameters:

  • contentArray Array
  • [options] Object optional

    An optional argument to provide rendering settings.

    • [readMore] Boolean optional

      Specifies if content body layout should be truncated, and read more links rendered.

  • cb Function

save

(
  • dto
  • [options]
  • cb
)
Attempts to persist the DTO. The function executes a series of events: 1) The format event is fired 2) When an ID is provided the object is retrieved from the database otherwise a new object is created. 3) The merge event is triggered 4) The validate event is triggered. If validation errors are detected the process halts and the function calls back with an error. 5) The beforeSave event is triggered 6) The object is persisted 7) The afterSave event is triggered

Parameters:

  • dto Object
  • [options] Object optional
    • [isCreate] Boolean optional
  • cb Function
    A callback that takes two parameters. The first is an error, if occurred. The second is the object that matches the specified query

setSectionClause

(
  • where
  • sectionId
)
static

Parameters:

  • where Object
  • sectionId String

setTopicClause

(
  • where
  • topicId
)
static

Parameters:

  • where Object
  • topicId String

update

(
  • dto
  • [options]
  • cb
)
Attempts to persist the DTO as an update. The function executes a series of events: 1) The format event is fired 2) When an ID is provided the object is retrieved from the database otherwise a new object is created. 3) The merge event is triggered 4) The validate event is triggered. If validation errors are detected the process halts and the function calls back with an error. 5) The beforeSave event is triggered 6) The object is persisted 7) The afterSave event is triggered

Parameters:

  • dto Object
  • [options] Object optional
  • cb Function
    A callback that takes two parameters. The first is an error, if occurred. The second is the object that matches the specified query

validate

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • data Object

      The DTO that was provided for persistence

      • page_topics Array
    • service PageService

      An instance of the service that triggered the event that called this handler

  • cb Function

    A callback that takes a single parameter: an error if occurred

validateHeadline

(
  • context
  • cb
)

Validates that a headline is provided and is unique

Parameters:

  • context Object
    • data Object
    • validationErrors Array
  • cb Function

    (Error)

Returns:

:

Properties

dao

DAO
An instance of DAO to be used to interact with the persistence layer

TYPE

String private static

type

String
Represents the name of the collection to interact with