Database

New in package 166

Syntax

Database.method(...);

Description

The predefined Database object is designed to allow MetaScript to globally access the database on which the MetaScript is being executed. The Database object is a top-level, predefined MetaScript object. You can access it without using a constructor or calling a method.

The Database object is only available in server-side MetaScript.

Properties

Property Description
appFamily  
types Collection of database entity types.
tags  

Methods

Entities

Method Description
repository(type) Returns a repository for querying and modifying database entities.
lookup(repository_or_type, id) Looks up any database entity associated with the current context, including newly created, deleted, existing etc.
[clone](entity, values) Creates a new entity from an existing one, overriding it with values.
saveChanges() Saves all the changes made in the current scope.
lock(entity_or_data) Lock an object.
unlock(entity_or_data) Unlock an object.

Transactions, queries etc

Method Description
transaction Executes specified function in a new transaction.
scope Executes specified function in a new scope (Database).
createScope Creates new scope object.
executeSql Executes specified SQL query.

Model

Method Description
addProperty(entity, 'property', descriptor) Adds an entity.property.
addProperty(type, 'property', descriptor) Adds an entity.property to all entities of the type.
addReference(entity, 'property', repository, 'field', options) Adds an entity.property which references a repository entity defined by the entity.[$fields].field.
addCollection(entity, 'property', query, options) Adds an entity.property which represents a collection of entities defined by the query.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.