Skip to content
defrex edited this page Jul 22, 2011 · 9 revisions

Models

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.

Create data versus Real data

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.

Data Types

Users

key: user

fields:

{
    name: string,
    avatar: string // gravitar md5 hash, not a url.
}

create:

{
    name: string
}

Listings

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, ...]
}

Offers

key: offer

fields:

{
    amount: number,
    listing: listing.id
}

relationships:

{
    messages: [message.id, ...]
}

Conversations

key: convo

fields:

{
    listing: listing.id
}

relationships:

{
    messages: [message.id, ...]
}

Messages

key: message

fields:

{
    message: string,
    convo: convo.id
}

Inquiries

key: inquiry

fields:

{
    question: string,
    answer: string,
    listing: listing.id
}

Clone this wiki locally