Class: Code

util.Code(metamodel, entityManagerFactory)

Representation of a Code which runs on Baqend.

Constructor

new Code(metamodel, entityManagerFactory)

Parameters:
Name Type Description
metamodel metamodel.Metamodel
entityManagerFactory EntityManagerFactory
Source:

Members

entityManagerFactory :EntityManagerFactory

Type:
Source:

metamodel :metamodel.Metamodel

Type:
Source:

Methods

deleteCode(type, codeType) → {Promise.<*>}

Deletes Baqend code identified by the given bucket and code type

Parameters:
Name Type Description
type metamodel.ManagedType | string

The entity type for the handler or the Name of the
Baqend code

codeType string

The type of the code

Source:
Returns:

succeed if the code was deleted

Type
Promise.<*>

functionToString(fn) → {string}

Converts the given function to a string

Parameters:
Name Type Description
fn function

The JavaScript function to serialize

Source:
Returns:

The serialized function

Type
string

loadCode(type, codeType, asFunction) → {Promise.<function()>}

Loads Baqend code which will be identified by the given bucket and code type

Parameters:
Name Type Description
type metamodel.ManagedType | string

The entity type for the handler or the Name of the
Baqend code

codeType string

The type of the code

asFunction true

set it to true, to parse the code as a function and return it
instead of a string

Source:
Returns:

The code as parsed function

Type
Promise.<function()>

loadCode(type, codeType, asFunctionopt) → {Promise.<string>}

Loads Baqend code which will be identified by the given bucket and code type

Parameters:
Name Type Attributes Default Description
type metamodel.ManagedType | string

The entity type for the handler or the Name of the
Baqend code

codeType string

The type of the code

asFunction false <optional>
false

set it to true, to parse the code as a function and return it
instead of a string

Source:
Returns:

The code as string

Type
Promise.<string>

loadModules() → {Promise.<Array.<string>>}

Loads a list of all available modules without handlers

Source:
Returns:
Type
Promise.<Array.<string>>

saveCode(type, codeType, fn) → {Promise.<function()>}

Saves Baqend code which will be identified by the given bucket and code type

Parameters:
Name Type Description
type metamodel.ManagedType | string

The entity type for the handler or the Name of the
Baqend code

codeType string

The type of the code

fn function

Baqend code as a function

Source:
Returns:

The stored code as a parsed function

Type
Promise.<function()>

saveCode(type, codeType, fn) → {Promise.<string>}

Saves Baqend code which will be identified by the given bucket and code type

Parameters:
Name Type Description
type metamodel.ManagedType | string

The entity type for the handler or the Name of the
Baqend code

codeType string

The type of the code

fn string

Baqend code as a string

Source:
Returns:

The stored code as a string

Type
Promise.<string>

stringToFunction(signature, code) → {function}

Converts the given string to a module wrapper function

Parameters:
Name Type Description
signature Array.<string>

The expected parameters of the function

code string

The JavaScript function to deserialize

Source:
Returns:

The deserialized function

Type
function