Interface: baqend

baqend

Extends

Members

[YourEntityClass: string] :*

An Object factory for entity or embedded objects,
that can be accessed by the type name of the entity type.
An object factory can be called to create new instances of the type.
The created instances implements the binding.Entity or the binding.Managed interface
whenever the class is an entity or embedded object

Type:
  • *
Inherited From:
Source:

Device :binding.DeviceFactory

An Device factory for user objects.
The Device factory can be called to create new instances of devices or can be used to register, push to and
check registration status of devices.

Type:
Inherited From:
Source:

File :binding.FileFactory

A File factory for file objects.
The file factory can be called to create new instances for files.
The created instances implements the binding.File interface

Type:
Inherited From:
Source:

isOpen :boolean

Determine whether the entity manager is open.
true until the entity manager has been closed

Type:
  • boolean
Inherited From:
Source:

isReady :boolean

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

Type:
  • boolean
Inherited From:
Source:

Role :binding.EntityFactory.<model.Role>

An Role factory for role objects.
The Role factory can be called to create new instances of roles, later on users can be attached to roles to manage the
access permissions through this role
The created instances implements the model.Role interface

Type:
Inherited From:
Source:

token :String

The authentication token if the user is logged in currently

Type:
  • String
Overrides:
Source:

User :binding.UserFactory

An User factory for user objects.
The User factory can be called to create new instances of users or can be used to register/login/logout users.
The created instances implements the model.User interface

Type:
Inherited From:
Source:

Methods

addToBlackList(objectId)

Adds the given object id to the cacheBlackList if needed.

Parameters:
Name Type Description
objectId string

The id to add.

Inherited From:
Source:

addToWhiteList(objectId)

Adds the given object id to the cacheWhiteList if needed.

Parameters:
Name Type Description
objectId string

The id to add.

Inherited From:
Source:

attach(entity)

Attach the instance to this database context, if it is not already attached

Parameters:
Name Type Description
entity Entity

The entity to attach

Inherited From:
Source:

clear()

Clear the persistence context, causing all managed entities to become detached.
Changes made to entities that have not been flushed to the database will not be persisted.

Inherited From:
Source:

close()

Close an application-managed entity manager. After the close method has been invoked,
all methods on the EntityManager instance and any Query and TypedQuery objects obtained from it
will throw the IllegalStateError except for transaction, and isOpen (which will return false).
If this method is called when the entity manager is associated with an active transaction,
the persistence context remains managed until the transaction completes.

Inherited From:
Source:

configure(options) → {baqend}

Configures the DB with additional config options

Parameters:
Name Type Description
options Object

The additional configuration options

Properties
Name Type Attributes Default Description
tokenStorage TokenStorage <optional>

The tokenStorage which should be used by this emf

tokenStorageFactory TokenStorageFactory <optional>

The tokenStorage factory implementation which should
be used for token storage

staleness number <optional>
60

The maximum staleness of objects that are acceptable while reading cached data,
0 to always bypass the browser cache

Source:
Returns:
Type
baqend

connect(hostOrApp, secureopt, doneCallbackopt, failCallbackopt) → {Promise.<EntityManager>}

Connects the DB with the server and calls the callback on success

Parameters:
Name Type Attributes Default Description
hostOrApp string

The host or the app name to connect with

secure boolean <optional>
false

true To use a secure connection

doneCallback Lockable~callback <optional>

The callback, called when a connection is established and the
SDK is ready to use

failCallback Lockable~callback <optional>

When an error occurred while initializing the SDK

Source:
Returns:
Type
<EntityManager>

connected(connector, connectData, tokenStorage)

Connects this entityManager, used for synchronous and asynchronous initialization

Parameters:
Name Type Description
connector Connector
connectData Object
tokenStorage TokenStorage

The used tokenStorage for token persistence

Inherited From:
Source:

contains(entity) → {boolean}

Check if the instance is a managed entity instance belonging to the current persistence context.

Parameters:
Name Type Description
entity Entity

entity instance

Inherited From:
Source:
Returns:

boolean indicating if entity is in persistence context

Type
boolean

containsById(entity) → {boolean}

Check if an object with the id from the given entity is already attached.

Parameters:
Name Type Description
entity Entity

entity instance

Inherited From:
Source:
Returns:

boolean indicating if entity with same id is attached

Type
boolean

createQueryBuilder(resultClassopt) → {query.Builder.<*>}

Creates an instance of Query.Builder for query creation and execution. The Query results are instances of the
resultClass argument.

Parameters:
Name Type Attributes Description
resultClass <*> <optional>

the type of the query result

Inherited From:
Source:
Returns:

A query builder to create one ore more queries for the specified class

Type
<*>

createURL(relativePath, authorizeopt) → {string}

Creates a absolute url for the given relative one

Parameters:
Name Type Attributes Description
relativePath string

the relative url

authorize boolean <optional>

indicates if authorization credentials should be generated and be attached to the url

Inherited From:
Source:
Returns:

a absolute url wich is optionaly signed with a resource token which authenticates the currently
logged in user

Type
string

delete(entity, options) → {Promise.<binding.Entity>}

Delete the entity instance.

Parameters:
Name Type Description
entity Entity
options Object

The delete options

Inherited From:
Source:
Returns:
Type
Entity>

detach(entity)

Remove the given entity from the persistence context, causing a managed entity to become detached.
Unflushed changes made to the entity if any (including removal of the entity),
will not be synchronized to the database. Entities which previously referenced the detached entity will continue to reference it.

Parameters:
Name Type Description
entity Entity

entity instance

Inherited From:
Source:

ensureBloomFilterFreshness()

Checks the freshness of the bloom filter and does a reload if necessary

Inherited From:
Source:

ensureCacheHeader(id, message, refresh)

Parameters:
Name Type Description
id string

To check the bloom filter

message Message

To attach the headers

refresh boolean

To force the reload headers

Inherited From:
Source:

flush() → {Promise.<*>}

Synchronize the persistence context to the underlying database.

Inherited From:
Source:
Returns:
Type
<*>

GeoPoint(latitudeopt, longitudeopt) → {void}

Constructor for a new GeoPoint

Parameters:
Name Type Attributes Description
latitude string | number | Object | <number> <optional>

A coordinate pair (latitude first), a GeoPoint like object or the GeoPoint's latitude

longitude number <optional>

The GeoPoint's longitude

Inherited From:
Source:
Returns:

The new created GeoPoint

Type
void

getReference(entityClass, keyopt)

Get an instance, whose state may be lazily fetched. If the requested instance does not exist
in the database, the EntityNotFoundError is thrown when the instance state is first accessed.
The application should not expect that the instance state will be available upon detachment,
unless it was accessed by the application while the entity manager was open.

Parameters:
Name Type Attributes Description
entityClass Entity> | string
key string <optional>
Inherited From:
Source:

getSubEntities(entity, depth, resolvedopt, initialEntityopt) → {Array.<binding.Entity>}

Returns all referenced sub entities for the given depth and root entity

Parameters:
Name Type Attributes Description
entity Entity
depth boolean | number
resolved Entity> <optional>
initialEntity Entity <optional>
Inherited From:
Source:
Returns:
Type
Entity>

getSubEntitiesByPath(entity, path) → {Array.<binding.Entity>}

Returns all referenced one level sub entities for the given path

Parameters:
Name Type Description
entity Entity
path <string>
Inherited From:
Source:
Returns:
Type
Entity>

insert(entity, options) → {Promise.<binding.Entity>}

Parameters:
Name Type Description
entity Entity
options Object
Inherited From:
Source:
Returns:
Type
Entity>

List(…args) → {void}

Constructor for a new List collection

Parameters:
Name Type Attributes Description
args * <repeatable>

Same arguments can be passed as the Array constructor takes

Inherited From:
Source:
Returns:

The new created List

Type
void

load(entityClass, oid, optionsopt) → {Promise.<binding.Entity>}

Search for an entity of the specified oid.
If the entity instance is contained in the persistence context, it is returned from there.

Parameters:
Name Type Attributes Description
entityClass Entity> | string

entity class

oid String

Object ID

options Object <optional>

The load options.

Inherited From:
Source:
Returns:

the loaded entity or null

Type
Entity>

Map(collectionopt) → {void}

Constructor for a new Map collection

Parameters:
Name Type Attributes Description
collection <*> <optional>

The initial array or collection to initialize the new Map

Inherited From:
Source:
Returns:

The new created Map

Type
void

mustRevalidate(id) → {boolean}

Checks for a given id, if revalidation is required, the resource is stale or caching was disabled

Parameters:
Name Type Description
id string

The object id to check

Inherited From:
Source:
Returns:

Indicates if the resource must be revalidated

Type
boolean

optimisticSave(entity, cb) → {Promise.<binding.Entity>}

Parameters:
Name Type Description
entity Entity
cb function

pre-safe callback

Inherited From:
Source:
Returns:
Type
Entity>

persist(entity)

Make an instance managed and persistent.

Parameters:
Name Type Description
entity Entity

entity instance

Inherited From:
Source:

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

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

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

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

failCallback Lockable~callback <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
Lockable>

refresh(entity, options) → {Promise.<binding.Entity>}

Refresh the state of the instance from the database, overwriting changes made to the entity, if any.

Parameters:
Name Type Description
entity Entity

entity instance

options Object

The refresh options

Inherited From:
Source:
Returns:
Type
Entity>

resolveDepth(entity, optionsopt) → {Promise.<binding.Entity>}

Resolve the depth by loading the referenced objects of the given entity.

Parameters:
Name Type Attributes Description
entity Entity

entity instance

options Object <optional>

The load options

Inherited From:
Source:
Returns:
Type
Entity>

save(entity, options, withoutLockopt) → {Promise.<binding.Entity>}

Parameters:
Name Type Attributes Description
entity Entity
options Object

The save options

withoutLock boolean <optional>

Set true to save the entity without locking

Inherited From:
Source:
Returns:
Type
Entity>

Set(collectionopt) → {void}

Constructor for a new Set collection

Parameters:
Name Type Attributes Description
collection <*> <optional>

The initial array or collection to initialize the new Set

Inherited From:
Source:
Returns:

The new created Set

Type
void

update(entity, options) → {Promise.<binding.Entity>}

Parameters:
Name Type Description
entity Entity
options Object
Inherited From:
Source:
Returns:
Type
Entity>

validate(entity) → {util.ValidationResult}

The given entity will be checked by the validation code of the entity type.

Parameters:
Name Type Description
entity Entity
Inherited From:
Source:
Returns:

result

Type
ValidationResult

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

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

Parameters:
Name Type Attributes Default Description
callback 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:
Source:
Throws:

If the lock can't be aquired

Type
Error
Returns:

A promise

Type
Lockable>