-
Notifications
You must be signed in to change notification settings - Fork 2
Models
defrex edited this page Jul 22, 2011
·
9 revisions
All models must have the following fields
{
id: string,
created: timestamp,
modified: timestamp,
deleted: boolean,
creator: user.id
}
None of these fields can be altered by the client.
Models are created via a create method (See Protocol). The data passed to create is not the same as the data returned by sub, though it will be similar. Think of create as more of calling a constructor than performing an insert operation. The above mandatory fields, for example, are not sent to create, but are added by the server. The differences for each data type will be noted, excluding the above global fields.
key: user
fields:
{
name: string,
avatar: string // gravitar md5 hash, not a url.
}
create:
{
name: string
}
key: listing
fields:
{
photo: string,
description: string,
latitude: number,
longitude: number,
price: number,
sold: boolean
}
relationships: (TODO: document how these work).
{
accepted: offer.id,
offers: [offer.id, ...],
inqueries: [inquiry.id, ...],
convos: [convo.id, ...]
}
key: offer
fields:
{
amount: number,
listing: listing.id
}
relationships:
{
messages: [message.id, ...]
}
key: convo
fields:
{
listing: listing.id
}
relationships:
{
messages: [message.id, ...]
}
key: message
fields:
{
message: string,
convo: convo.id
}
key: inquiry
fields:
{
question: string,
answer: string,
listing: listing.id
}