ServerRepository

@unitybase/base/ServerRepository~ ServerRepository

Create a new server side repository. Implement ServerRepository#select method able to return initialized TubDataStore

Usually created using fabric function conn.Repository

Constructor

new ServerRepository(connection, entityName)

Arguments:
  1. connection (UBConnection|null)  The remote server connection or null for internal server thread
  2. entityName (String)  name of Entity we create for
Example
let store = UB.Repository('my_entity')
   .attrs('id')
   .where('code', 'in', ['1', '2', '3'])  // code in ('1', '2', '3')
   .where('name', 'contains', 'Homer'). // name like '%homer%'
   .where('birtday', 'geq', new Date()) //(birtday >= '2012-01-01')
   .where('birtday', 'leq', new Date() + 10) // AND (birtday <= '2012-01-02')
   .where('[age] -10', '>=', {age: 15}, 'byAge') // (age + 10 >= 15)
   .where('', 'match', 'myvalue') // perform full text search for entity (require fts mixin)
   .logic('(byStrfType OR bySrfKindID)AND(dasdsa)')
   .select()

Extends

Members

ubRequest protected

Deprecated:
  • Will be removed in UB 2.0. Use .ubql() instead

WhereCondition: string

Enumeration of all condition types. This enumeration defines a set of String values. It exists primarily for documentation purposes - in code use the actual string values like '>', don't reference them through this class like WhereCondition.more.

We define several aliases for the same condition. In case of direct HTTP request (without Repository) use only non-aliased values (i.e. more instead of '>' or 'gt')

Properties:
Name Type Description
gt string
">" string
more string
lt string
"<" string
less string
eq string
"=" string
equal string
ge string
geq string
">=" string
moreEqual string
le string
leq string
"<=" string
lessEqual string
ne string
neq string
"<>" string
"!=" string
"!==" string
notEqual string
contains string
like string
notContains string
notLike string
isNull string
null string
notNull string
notIsNull string
isNotNull string
beginWith string
startWith string
startsWith string
startswith string
notBeginWith string
notStartWith string
notStartsWith string
includes string
in string
notIncludes string
notIn string
match string
subquery string
exists string
notExists string
custom string

Methods

selectAsObject(resultInPlainTextopt) → Array.<Object>|String

Arguments:
  1. [resultInPlainText=false] (Boolean)  If true - result is {String}

selectAsArray(resultInPlainTextopt)TubCachedData|String

Arguments:
  1. [resultInPlainText=false] (Boolean)  If true - result is {String}

selectAsStore(instanceopt)TubDataStore|Array.<Object>

Create new, or use passed as parameter TubDataStore and run TubDataStore#select method passing result of CustomRepository#getRunListItem as config. Do not work for remote connection.
Arguments:
  1. [instance] (TubDataStore)  Optional instance for in-thread execution context. If passed - run select for it (not create new instance) and return instance as a result. Be careful - method do not check instance is created for entity you pass to Repository constructor.

select(instanceopt)TubDataStore

Arguments:
  1. [instance] (TubDataStore)  Optional instance for in-thread execution context. If passed - run select for it (not create new instance) and return instance as a result.

selectSingle()Object|undefined

Select a single row. If ubql result is empty - return {undefined}.

WARNING method do not check repository conntains the single row and always return a first row from result.

selectScalar()Object|undefined

Perform select and return a value of the first attribute from the first row

WARNING method do not check repository contains the single row

selectById(ID)Object|undefined

Select a single row by ID. If ubql result is empty - return {undefined}.
Arguments:
  1. ID (Number)  Row identifier