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:

(readonly) bloomFilter :caching.BloomFilter

Type:
Inherited From:
Source:

bloomFilterLock

Bloom filter refresh Promise

Inherited From:
Source:

(readonly) bloomFilterRefresh :number

Bloom filter refresh interval in seconds.

Type:
  • number
Inherited From:
Source:

cacheBlackList

Set of object ids that were updated but are not yet included in the bloom filter.
This set essentially implements revalidation by side effect which does not work in Chrome.

Inherited From:
Source:

cacheWhiteList

Set of object ids that were revalidated after the Bloom filter was loaded.

Inherited From:
Source:

(readonly) code :util.Code

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:

(readonly) deviceMe :model.Device|null

The current registered device object

Type:
Inherited From:
Source:

(readonly) entityManagerFactory :EntityManagerFactory

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:

(readonly) isCachingDisabled :boolean

Whether caching is disabled

Type:
  • boolean
Inherited From:
Source:

(readonly) isDeviceRegistered :boolean

Returns true if the device token is already registered, otherwise false.

Type:
  • boolean
Inherited From:
Source:

(readonly) 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:

(readonly) log :util.Logger

Log messages can created by calling log directly as function, with a specific log level or with the helper
methods, which a members of the log method.

Logs will be filtered by the client logger and the before they persisted. The default log level is
'info' therefore all log messages below the given message aren't persisted.

Examples:

     // default log level ist info
     db.log('test message %s', 'my string');
     // info: test message my string

     // pass a explicit log level as the first argument, one of ('trace', 'debug', 'info', 'warn', 'error')
     db.log('warn', 'test message %d', 123);
     // warn: test message 123

     // debug log level will not be persisted by default, since the default logging level is info
     db.log('debug', 'test message %j', {number: 123}, {});
     // debug: test message {"number":123}
     // data = {}

     // One additional json object can be provided, which will be persisted together with the log entry
     db.log('info', 'test message %s, %s', 'first', 'second', {number: 123});
     // info: test message first, second
     // data = {number: 123}

     //use the log level helper
     db.log.info('test message', 'first', 'second', {number: 123});
     // info: test message first second
     // data = {number: 123}

     //change the default log level to trace, i.e. all log levels will be persisted, note that the log level can be
     //additionally configured in the baqend
     db.log.level = 'trace';

     //trace will be persisted now
     db.log.trace('test message', 'first', 'second', {number: 123});
     // info: test message first second
     // data = {number: 123}
Type:
Inherited From:
Source:

(readonly) me :model.User|null

The current logged in user object

Type:
Inherited From:
Source:

(readonly) metamodel :metamodel.Metamodel

Type:
Inherited From:
Source:

(readonly) modules :util.Modules

Type:
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:

(readonly) tokenStorage :util.TokenStorage

Returns the tokenStorage which will be used to authorize all requests.

Type:
Inherited From:
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) → {void}

Adds the given object id to the cacheBlackList if needed.

Parameters:
Name Type Description
objectId string

The id to add.

Inherited From:
Source:
Returns:
Type
void

addToWhiteList(objectId) → {void}

Adds the given object id to the cacheWhiteList if needed.

Parameters:
Name Type Description
objectId string

The id to add.

Inherited From:
Source:
Returns:
Type
void

attach(entity) → {void}

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

Parameters:
Name Type Description
entity binding.Entity

The entity to attach

Inherited From:
Source:
Returns:
Type
void

clear() → {void}

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:
Returns:
Type
void

close() → {void}

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:
Returns:
Type
void

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 util.TokenStorage <optional>

The tokenStorage which should be used by this emf

tokenStorageFactory util.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 util.Lockable~doneCallback <optional>

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

failCallback util.Lockable~failCallback <optional>

When an error occurred while initializing the SDK

Source:
Returns:
Type
Promise.<EntityManager>

connected(connector, connectData, tokenStorage) → {void}

Connects this entityManager, used for synchronous and asynchronous initialization

Parameters:
Name Type Description
connector connector.Connector
connectData Object
tokenStorage util.TokenStorage

The used tokenStorage for token persistence

Inherited From:
Source:
Returns:
Type
void

contains(entity) → {boolean}

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

Parameters:
Name Type Description
entity binding.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 binding.Entity

entity instance

Inherited From:
Source:
Returns:

boolean indicating if entity with same id is attached

Type
boolean

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

Creates an instance of query.Builder.<T> for query creation and execution

The query results are instances of the resultClass argument.

Parameters:
Name Type Attributes Description
resultClass Class.<T> <optional>

the type of the query result

Inherited From:
  • EntityManager#createQueryBuilder<T>
Source:
Returns:

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

Type
query.Builder.<T>

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 binding.Entity
options Object

The delete options

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

detach(entity) → {Promise.<binding.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 binding.Entity

The entity instance to detach.

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

ensureBloomFilterFreshness() → {void}

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

Inherited From:
Source:
Returns:
Type
void

ensureCacheHeader(id, message, refresh) → {void}

Parameters:
Name Type Description
id string

To check the bloom filter

message connector.Message

To attach the headers

refresh boolean

To force the reload headers

Inherited From:
Source:
Returns:
Type
void

flush() → {Promise.<*>}

Synchronize the persistence context to the underlying database.

Inherited From:
Source:
Returns:
Type
Promise.<*>

GeoPoint(latitudeopt, longitudeopt) → {GeoPoint}

Constructor for a new GeoPoint

Parameters:
Name Type Attributes Description
latitude string | number | Object | Array.<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
GeoPoint

getReference(entityClass, keyopt) → {binding.Entity}

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 Class.<binding.Entity> | string
key string <optional>
Inherited From:
Source:
Returns:
Type
binding.Entity

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 binding.Entity
depth boolean | number
resolved Array.<binding.Entity> <optional>
initialEntity binding.Entity <optional>
Inherited From:
Source:
Returns:
Type
Array.<binding.Entity>

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

Returns all referenced one level sub entities for the given path

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

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

Parameters:
Name Type Description
entity binding.Entity
options Object
Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

List(…args) → {Array.<U>}

Constructor for a new List collection

Parameters:
Name Type Attributes Description
args U <repeatable>

Same arguments can be passed as the Array constructor takes

Inherited From:
  • EntityManager#List<U>
Source:
Returns:

The new created List

Type
Array.<U>

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 Class.<binding.Entity> | string

entity class

oid String

Object ID

options Object <optional>

The load options.

Inherited From:
Source:
Returns:

the loaded entity or null

Type
Promise.<binding.Entity>

Map(collectionopt) → {Map.<*, *>}

Constructor for a new Map collection

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

The initial array or collection to initialize the new Map

Inherited From:
Source:
Returns:

The new created Map

Type
Map.<*, *>

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

openOAuthWindow(url, targetOrTitle, options) → {void}

Opens a new window use for OAuth logins

Parameters:
Name Type Description
url string

The url to open

targetOrTitle string

The target of the window, or the title of the popup

options object

Additional window options

Inherited From:
Source:
Returns:
Type
void

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

Parameters:
Name Type Description
entity binding.Entity
cb function

pre-safe callback

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

persist(entity) → {void}

Make an instance managed and persistent.

Parameters:
Name Type Description
entity binding.Entity

entity instance

Inherited From:
Source:
Returns:
Type
void

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>

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 binding.Entity

entity instance

options Object

The refresh options

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

registerDevice(devicetype, subscription, device) → {Promise.<model.Device>}

Parameters:
Name Type Description
devicetype string

The OS of the device (IOS/Android)

subscription object

WebPush subscription

device model.Device
Inherited From:
Source:
Returns:
Type
Promise.<model.Device>

requestAPIToken(entityClass, user) → {Promise.<*>}

Requests a perpetual token for the given user

Only users with the admin role are allowed to request an API token.

Parameters:
Name Type Description
entityClass Class.<binding.Entity> | Class.<binding.Managed>
user binding.User | String

The user object or id of the user object

Inherited From:
Source:
Returns:
Type
Promise.<*>

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

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

Parameters:
Name Type Attributes Description
entity binding.Entity

entity instance

options Object <optional>

The load options

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

revokeAllTokens(entityClass, user) → {Promise.<*>}

Revoke all created tokens for the given user

This method will revoke all previously issued tokens and the user must login again.

Parameters:
Name Type Description
entityClass Class.<binding.Entity> | Class.<binding.Managed>
user binding.User | String

The user object or id of the user object

Inherited From:
Source:
Returns:
Type
Promise.<*>

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

Parameters:
Name Type Attributes Description
entity binding.Entity
options Object

The save options

withoutLock boolean <optional>

Set true to save the entity without locking

Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

Set(collectionopt) → {Set.<U>}

Constructor for a new Set collection

Parameters:
Name Type Attributes Description
collection Iterable.<U> <optional>

The initial array or collection to initialize the new Set

Inherited From:
  • EntityManager#Set<U>
Source:
Returns:

The new created Set

Type
Set.<U>

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

Parameters:
Name Type Description
entity binding.Entity
options Object
Inherited From:
Source:
Returns:
Type
Promise.<binding.Entity>

validate(entity) → {util.ValidationResult}

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

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

result

Type
util.ValidationResult

(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>