Home Manual Reference Source Test
public class | source

AttributeJoinedData

Extends:

Attribute → AttributeJoinedData

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

Method Summary

Public Methods
public

fromJSON(val: *): *

public

includeSQL(klass: *): string

public
public

toJSON(val: *): *

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": *, "modelTable": *, "queryable": *}) source

Override:

Attribute#constructor

Params:

NameTypeAttributeDescription
objectPattern {"modelKey": *, "jsonKey": *, "modelTable": *, "queryable": *}
  • default: {"modelKey":null,"jsonKey":null,"modelTable":null,"queryable":null}

Public Members

public modelTable: * source

Public Methods

public fromJSON(val: *): * source

Override:

Attribute#fromJSON

Params:

NameTypeAttributeDescription
val *

Return:

*

public includeSQL(klass: *): string source

Params:

NameTypeAttributeDescription
klass *

Return:

string

public selectSQL(): string source

Return:

string

public toJSON(val: *): * source

Override:

Attribute#toJSON

Params:

NameTypeAttributeDescription
val *

Return:

*