import AttributeCollection from 'electron-coresqlite/lib/attributes/attribute-collection.js'AttributeCollection
Extends:
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 |
ItemClass: * |
|
| public |
joinOnField: * |
|
| public |
|
|
Method Summary
| Public Methods | ||
| public |
|
|
| public |
containsAny(vals: *): * |
|
| public |
fromJSON(json: *): * |
|
| public |
toJSON(vals: *): * |
|
Inherited Summary
| From class Attribute | ||
| public |
jsonKey: * |
|
| public |
modelKey: * |
|
| public |
queryable: * |
|
| public |
|
|
| public |
|
|
| public |
|
|
| public |
fromJSON(val: *): * |
|
| public |
|
|
| public |
|
|
| public |
toJSON(val: *): * |
|
Public Constructors
public constructor(objectPattern: {"modelKey": *, "jsonKey": *, "itemClass": *, "joinOnField": *, "joinQueryableBy": *, "queryable": *}) source
Override:
Attribute#constructorParams:
| Name | Type | Attribute | Description |
| objectPattern | {"modelKey": *, "jsonKey": *, "itemClass": *, "joinOnField": *, "joinQueryableBy": *, "queryable": *} |
|
Public Members
public ItemClass: * source
public joinOnField: * source
public joinQueryableBy: * source
Public Methods
public fromJSON(json: *): * source
Override:
Attribute#fromJSONParams:
| Name | Type | Attribute | Description |
| json | * |
Return:
| * |
public toJSON(vals: *): * source
Override:
Attribute#toJSONParams:
| Name | Type | Attribute | Description |
| vals | * |
Return:
| * |