Class: Metamodel

metamodel.Metamodel(entityManagerFactoryopt)

new Metamodel(entityManagerFactoryopt)

Constructs a new metamodel instance which represents the complete schema of one baqend app

Parameters:
Name Type Attributes Description
entityManagerFactory EntityManagerFactory <optional>
Source:

Extends

Members

baseTypes :Object.<string, metamodel.BasicType>

Type:
  • Object.<string, metamodel.BasicType>
Source:

embeddables :Object.<string, metamodel.EmbeddableType>

Type:
  • Object.<string, metamodel.EmbeddableType>
Source:

enhancer :binding.Enhancer

Type:
Source:

entities :Object.<string, metamodel.EntityType>

Type:
  • Object.<string, metamodel.EntityType>
Source:

entityManagerFactory :EntityManagerFactory

Type:
Source:

isInitialized :boolean

Defines if the Metamodel has been finalized

Type:
  • boolean
Source:

isReady :boolean

Indicates if there is currently no exclusive operation executed
true If no exclusive lock is hold

Type:
  • boolean
Inherited From:
Source:

Methods

addType(type) → {metamodel.Type}

Parameters:
Name Type Description
type metamodel.Type
Source:
Returns:

the added type

Type
metamodel.Type

baseType(typeConstructor) → {metamodel.BasicType}

Return the metamodel basic type representing the native class.

Parameters:
Name Type Description
typeConstructor Class.<*> | string

the type of the represented native class

Source:
Returns:

the metamodel basic type

Type
metamodel.BasicType

createIndex(bucket, index) → {Promise.<*>}

Creates an index

Parameters:
Name Type Description
bucket string

Name of the Bucket

index metamodel.DbIndex

Will be applied for the given bucket

Source:
Returns:
Type
Promise.<*>

dropAllIndexes(bucket) → {Promise.<*>}

Drops all indexes

Parameters:
Name Type Description
bucket string

Indexes will be dropped for the given bucket

Source:
Returns:
Type
Promise.<*>

dropIndex(bucket, index) → {Promise.<*>}

Drops an index

Parameters:
Name Type Description
bucket string

Name of the Bucket

index metamodel.DbIndex

Will be dropped for the given bucket

Source:
Returns:
Type
Promise.<*>

embeddable(typeConstructor) → {metamodel.EmbeddableType}

Return the metamodel embeddable type representing the embeddable class.

Parameters:
Name Type Description
typeConstructor Class.<binding.Managed> | string

the type of the represented embeddable class

Source:
Returns:

the metamodel embeddable type

Type
metamodel.EmbeddableType

entity(typeConstructor) → {metamodel.EntityType}

Return the metamodel entity type representing the entity.

Parameters:
Name Type Description
typeConstructor Class.<binding.Entity> | string

the type of the represented entity

Source:
Returns:

the metamodel entity type

Type
metamodel.EntityType

fromJSON(json) → {void}

Replace the current schema by the provided one in json

Parameters:
Name Type Description
json json

The json schema data

Source:
Returns:
Type
void

getIndexes(bucket) → {Promise.<Array.<metamodel.DbIndex>>}

Loads all indexes for the given bucket

Parameters:
Name Type Description
bucket string

Current indexes will be loaded for the given bucket

Source:
Returns:
Type
Promise.<Array.<metamodel.DbIndex>>

getRef(arg) → {string}

Parameters:
Name Type Description
arg Class.<binding.Managed> | string
Source:
Returns:
Type
string

init(jsonMetamodelopt) → {void}

Prepare the Metamodel for custom schema creation

Parameters:
Name Type Attributes Description
jsonMetamodel Object <optional>

initialize the metamodel with the serialized json schema

Source:
Returns:
Type
void

load() → {Promise.<metamodel.Metamodel>}

Load all schema data from the server

Source:
Returns:
Type
Promise.<metamodel.Metamodel>

managedType(typeConstructor) → {metamodel.Type}

Return the metamodel managed type representing the entity, mapped superclass, or embeddable class.

Parameters:
Name Type Description
typeConstructor Class.<binding.Managed> | string

the type of the represented managed class

Source:
Returns:

the metamodel managed type

Type
metamodel.Type

ready(doneCallbackopt, failCallbackopt) → {Promise.<this>}

Waits on the previously requested operation and calls the doneCallback if the operation is fulfilled

Parameters:
Name Type Attributes Description
doneCallback util.Lockable~doneCallback <optional>

The callback which will be invoked when the previously
operations on this object is completed.

failCallback util.Lockable~failCallback <optional>

When the lock can't be released caused by a none
recoverable error

Inherited From:
Source:
Returns:

A promise which completes successfully, when the previously requested
operation completes

Type
Promise.<this>

save(managedTypeopt) → {Promise.<metamodel.Metamodel>}

Store all local schema data on the server, or the provided one

Note: The schema must be initialized, by init or load

Parameters:
Name Type Attributes Description
managedType metamodel.ManagedType <optional>

The specific type to persist, if omitted the complete schema
will be updated

Source:
Returns:
Type
Promise.<metamodel.Metamodel>

toJSON() → {json}

Get the current schema types as json

Source:
Returns:

the json data

Type
json

update(data) → {Promise.<metamodel.Metamodel>}

Update the metamodel with the schema

The provided data object will be forwarded to the UpdateAllSchemas resource.
The underlying schema of this Metamodel object will be replaced by the result.

Parameters:
Name Type Description
data json

The JSON which will be send to the UpdateAllSchemas resource.

Source:
Returns:
Type
Promise.<metamodel.Metamodel>

(protected) withLock(callback, criticalopt) → {Promise.<T>}

Try to aquire an exclusive lock and executes the given callback.

Parameters:
Name Type Attributes Default Description
callback util.Lockable~callback

The exclusive operation to execute

critical boolean <optional>
false

Indicates if the operation is critical. If the operation is critical and the
operation fails, then the lock will not be released

Inherited From:
  • util.Lockable#withLock<T>
Source:
Throws:

If the lock can't be aquired

Type
Error
Returns:

A promise

Type
Promise.<T>