import AttributeJoinedData from 'electron-coresqlite/lib/attributes/attribute-joined-data.js'AttributeJoinedData
Extends:
Joined Data attributes allow you to store certain attributes of an object in a separate table in the database. We use this attribute type for Message bodies. Storing message bodies, which can be very large, in a separate table allows us to make queries on message metadata extremely fast, and inflate Message objects without their bodies to build the thread list.
When building a query on a model with a JoinedData attribute, you need
to call include to explicitly load the joined data attribute.
The query builder will automatically perform a LEFT OUTER JOIN with
the secondary table to retrieve the attribute:
db.find(Message, '123').then (message) ->
// message.body is undefined
db.find(Message, '123').include(Message.attributes.body).then (message) ->
// message.body is defined
When you call persistModel, JoinedData attributes are automatically
written to the secondary table.
JoinedData attributes cannot be queryable.
Section: Database
Constructor Summary
| Public Constructor | ||
| public |
constructor(objectPattern: {"modelKey": *, "jsonKey": *, "modelTable": *, "queryable": *}) |
|
Member Summary
| Public Members | ||
| public |
modelTable: * |
|
Method Summary
| Public Methods | ||
| public |
fromJSON(val: *): * |
|
| public |
includeSQL(klass: *): string |
|
| public |
|
|
| public |
toJSON(val: *): * |
|
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": *, "modelTable": *, "queryable": *}) source
Override:
Attribute#constructorParams:
| Name | Type | Attribute | Description |
| objectPattern | {"modelKey": *, "jsonKey": *, "modelTable": *, "queryable": *} |
|
Public Members
public modelTable: * source
Public Methods
public fromJSON(val: *): * source
Override:
Attribute#fromJSONParams:
| Name | Type | Attribute | Description |
| val | * |
Return:
| * |
public toJSON(val: *): * source
Override:
Attribute#toJSONParams:
| Name | Type | Attribute | Description |
| val | * |
Return:
| * |