Home Manual Reference Source Test
public class | source

AttributeCollection

Extends:

Attribute → AttributeCollection

Collection attributes provide basic support for one-to-many relationships. For example, Threads in N1 have a collection of Labels or Folders.

When Collection attributes are marked as queryable, the RxDatabase automatically creates a join table and maintains it as you create, save, and delete models. When you call persistModel, entries are added to the join table associating the ID of the model with the IDs of models in the collection.

Collection attributes have an additional clause builder, contains:

db.findAll(Thread).where([Thread.attributes.categories.contains('inbox')])

This is equivalent to writing the following SQL:

SELECT `Thread`.`data` FROM `Thread`
INNER JOIN `ThreadLabel` AS `M1` ON `M1`.`id` = `Thread`.`id`
WHERE `M1`.`value` = 'inbox'
ORDER BY `Thread`.`last_message_received_timestamp` DESC

The value of this attribute is always an array of other model objects.

Section: Database

Constructor Summary

Public Constructor
public

constructor(objectPattern: {"modelKey": *, "jsonKey": *, "itemClass": *, "joinOnField": *, "joinQueryableBy": *, "queryable": *})

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

contains(val: *): Matcher

public

containsAny(vals: *): *

public

fromJSON(json: *): *

public

toJSON(vals: *): *

Inherited Summary

From class Attribute
public

jsonKey: *

public
public
public
public
public

equal(val: *): Matcher

public

fromJSON(val: *): *

public

in(val: Array): Matcher

public

not(val: *): Matcher

public

toJSON(val: *): *

Public Constructors

public constructor(objectPattern: {"modelKey": *, "jsonKey": *, "itemClass": *, "joinOnField": *, "joinQueryableBy": *, "queryable": *}) source

Override:

Attribute#constructor

Params:

NameTypeAttributeDescription
objectPattern {"modelKey": *, "jsonKey": *, "itemClass": *, "joinOnField": *, "joinQueryableBy": *, "queryable": *}
  • default: {"modelKey":null,"jsonKey":null,"itemClass":null,"joinOnField":null,"joinQueryableBy":null,"queryable":null}

Public Members

public ItemClass: * source

public joinOnField: * source

public joinQueryableBy: * source

Public Methods

public contains(val: *): Matcher source

Params:

NameTypeAttributeDescription
val *

Return:

Matcher

Matcher for objects containing the provided value.

public containsAny(vals: *): * source

Params:

NameTypeAttributeDescription
vals *

Return:

*

public fromJSON(json: *): * source

Override:

Attribute#fromJSON

Params:

NameTypeAttributeDescription
json *

Return:

*

public toJSON(vals: *): * source

Override:

Attribute#toJSON

Params:

NameTypeAttributeDescription
vals *

Return:

*