Manual Reference Source
public class | source

ODM

Direct Subclass:

app/modules/entities/apiuser/apiuser.js~ApiUser, app/modules/entities/chart/chart.js~Chart, app/modules/entities/config/config.js~Config, app/modules/entities/connector/connector.js~Connector, app/modules/entities/exporter/exporter.js~Exporter, app/modules/entities/form/form.js~Form, app/modules/entities/identifier/identifier.js~Identifier, app/modules/entities/importer/importer.js~Importer, app/modules/entities/lang/lang.js~Lang, app/modules/entities/mswpublication/mswpublication.js~MSWPublication, app/modules/entities/mail_template/mail_template.js~MailTemplate, app/modules/entities/menu/menu.js~Menu, app/modules/entities/function/function.js~PFunction, app/modules/entities/page/page.js~Page, app/modules/entities/pipeline/pipeline.js~Pipeline, app/modules/entities/publication/publication.js~Publication, app/modules/entities/query/query.js~Query, app/modules/entities/role/role.js~Role, app/modules/entities/template/template.js~Template, app/modules/entities/user/user.js~User, app/modules/entities/widget/widget.js~Widget, app/modules/entities/entity/entity.js~_Entity

Object Data Model Generic class to model an entity in the program (saved into an ElasticSearch DB).

Static Method Summary

Static Public Methods
public static

async bulk_create(index: string, type: string, client: Object, body: Array<Object>): PromiseODM>

public static

async bulk_update(index: string, type: string, client: Object, body: Array<Object>): PromiseODM>

public static

async count(index: string, type: string, client: Object, model: Object, search: Search): Promise<Object>

public static

async create(index: string, type: string, client: Object, model: Object, body: Object): PromiseODM>

public static

async deleteByQuery(index: string, type: string, client: Object, search: Search)

public static

async fetch_mapping(index: string, type: string, client: Object, include_meta: boolean): *

public static

async fetch_settings(index: string, type: string, client: Object): *

public static

format_hit(hit: Object, found: boolean): Object

Process an entity and create an {ODM} object.

public static

async pre_create_hook(index: string, type: string, client: Object, model: Object, body: Object): Promise<boolean>

public static

async pre_update_hook(index: string, type: string, client: Object, model: Object, body: Object, id: string): Promise<boolean>

public static

async read(index: string, type: string, client: Object, model: Object, response: Object, population: Array<String>, backward: boolean): Object

public static

async remove(index: string, type: string, client: Object, id: string): Promise<boolean>

public static

async search(index: string, type: string, client: Object, model: Object, search: Search, opts: Object): Promise<Object>

public static

async update(index: string, type: string, client: Object, model: Object, body: Object, id: string): PromiseODM>

Static Private Methods
private static

async _bulk_create_or_update(index: string, type: string, client: Object, body: Array<Object>, action: string): PromiseODM>

private static

async _create_or_update(index: string, type: string, client: Object, model: Object, body: Object, id: string): PromiseODM>

Constructor Summary

Public Constructor
public

constructor(client:: *, id:: *)

Member Summary

Public Members
public get

db: *: Object

Get all information about an entity;

public set

db(o:: *): Object

Set all interesting information about an entity

public get

id: *: string

Get id of an entity (possibly null)

public get
public get
public get
public get
public get

name: *: string

Get name of the class (= entity)

public get
public get

type: *: string

Private Members
private
private
private
private
private
private

Method Summary

Public Methods
public
public
public
public

async post_read_hook(population: Array<String>)

public
public

async pre_read_hook()

public

async read(opts: Object): Promise<ODM>

public
Private Methods
private

async _handle_population(population: Array<String>, propagate_population: boolean)

Static Public Methods

public static async bulk_create(index: string, type: string, client: Object, body: Array<Object>): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
body Array<Object>

Return:

PromiseODM>

public static async bulk_update(index: string, type: string, client: Object, body: Array<Object>): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
body Array<Object>

Return:

PromiseODM>

public static async count(index: string, type: string, client: Object, model: Object, search: Search): Promise<Object> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
search Search

Return:

Promise<Object>

public static async create(index: string, type: string, client: Object, model: Object, body: Object): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
body Object

Return:

PromiseODM>

public static async deleteByQuery(index: string, type: string, client: Object, search: Search) source

Params:

NameTypeAttributeDescription
index string
type string
client Object
search Search

public static async fetch_mapping(index: string, type: string, client: Object, include_meta: boolean): * source

Params:

NameTypeAttributeDescription
index string
type string
client Object
include_meta boolean
  • optional
  • default: undefined

Return:

*

public static async fetch_settings(index: string, type: string, client: Object): * source

Params:

NameTypeAttributeDescription
index string
type string
client Object

Return:

*

public static format_hit(hit: Object, found: boolean): Object source

Process an entity and create an {ODM} object.

Params:

NameTypeAttributeDescription
hit Object

hit in ElasticSearch result

found boolean
  • optional
  • default: true

true if the object was found in DB, false otherwise

Return:

Object

content of the hit

public static async pre_create_hook(index: string, type: string, client: Object, model: Object, body: Object): Promise<boolean> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
body Object

Return:

Promise<boolean>

public static async pre_update_hook(index: string, type: string, client: Object, model: Object, body: Object, id: string): Promise<boolean> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
body Object
id string

Return:

Promise<boolean>

public static async read(index: string, type: string, client: Object, model: Object, response: Object, population: Array<String>, backward: boolean): Object source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
response Object
population Array<String>
  • optional
  • default: undefined
backward boolean
  • optional
  • default: undefined

Return:

Object

public static async remove(index: string, type: string, client: Object, id: string): Promise<boolean> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
id string

Return:

Promise<boolean>

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
search Search
opts Object
  • optional
  • default: {}

Return:

Promise<Object>

public static async update(index: string, type: string, client: Object, model: Object, body: Object, id: string): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
body Object
id string

Return:

PromiseODM>

Static Private Methods

private static async _bulk_create_or_update(index: string, type: string, client: Object, body: Array<Object>, action: string): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
body Array<Object>
action string
  • optional
  • default: create

Return:

PromiseODM>

private static async _create_or_update(index: string, type: string, client: Object, model: Object, body: Object, id: string): PromiseODM> source

Params:

NameTypeAttributeDescription
index string
type string
client Object
model Object
body Object
id string
  • optional
  • default: undefined
  • nullable: true

Return:

PromiseODM>

Public Constructors

public constructor(client:: *, id:: *) source

Params:

NameTypeAttributeDescription
client: *

ElasticSearch client;

id: *

id of the entity (could be null)

Public Members

public get db: *: Object source

Get all information about an entity;

Return:

*

all interesting information

public set db(o:: *): Object source

Set all interesting information about an entity

public get id: *: string source

Get id of an entity (possibly null)

Return:

*

id

public get index: *: string source

Return:

*

the underlying ElasticSearch index of this entity

public get mapping: *: Object source

Return:

*

the underlying ElasticSearch mapping of this entity

public get messages: Object source

public get model: *: Object source

Return:

*

the underlying model of this entity

See:

public get name: *: string source

Get name of the class (= entity)

Return:

*

name of the class

public get source: Object source

public get type: *: string source

Return:

*

the underlying ElasticSearch type of this entity

Private Members

private _client: Object source

private _db: Object source

private _id: string source

private _index: string source

private _model: Object source

private _type: string source

Public Methods

public ocreate(): PromiseODM> source

Return:

PromiseODM>

public oupdate(): PromiseODM> source

Return:

PromiseODM>

public async post_create_hook() source

public async post_read_hook(population: Array<String>) source

Params:

NameTypeAttributeDescription
population Array<String>

public async post_update_hook() source

public async pre_read_hook() source

public async read(opts: Object): Promise<ODM> source

Params:

NameTypeAttributeDescription
opts Object
  • optional
  • default: {}

Return:

Promise<ODM>

public toJSON(): Object source

Return:

Object

Private Methods

private async _handle_population(population: Array<String>, propagate_population: boolean) source

Params:

NameTypeAttributeDescription
population Array<String>
propagate_population boolean
  • optional
  • default: undefined