new Location()
- Source:
- See:
A location of interest in the BioPocket platform, such as a travel office or biodiversity landmark.
Database columns
- id (
bigint
) - Internal ID (used for joins). - api_id (
uuid
) - External ID (used in the API). - name (
string
, max 150 chars) - Full name of the location. - short_name (
string
, optional, max 30 chars) - Optional short name of the location. - address_street (
string
, max 150 chars) - address_number (
string
, optional, max 10 chars) - Optional address number (there may not be a number for some addresses like lieux-dits). - address_zip_code (
string
, max 15 chars) - address_city (
string
, max 100 chars) - address_state (
string
, max 30 chars) - description (
text
) - photo_url (
string
, max 500 chars) - site_url (
string
, max 500 chars) - phone (
string
, max 20 chars) - geometry (
point
) - Geographical coordinates of the location. - properties (
json
) - Extra user-defined properties. - created_at (
datetime
) - Time at which the location was created. - updated_at (
datetime
) - Time at which the location was last modified (equal to the creation date if never modified).
Extends
Methods
parseFrom(source, properties, optionsopt) → {Model}
- Source:
- Inherited From:
Parses data from the specified source into this record's columns.
// The following code:
record.parseFrom(data, [ 'name', 'siteUrl' ]);
// Is equivalent to:
if (data.hasOwnProperty('name')) {
record.set('name', data.name);
}
if (data.hasOwnProperty('siteUrl')) {
record.set('site_url', data.siteUrl);
}
// The following code:
record.parseFrom(data, [ 'street', 'zipCode' ], { columnPrefix: 'address_', sourcePrefix: 'address.' });
// Is equivalent to:
if (data.hasOwnProperty('address') && data.address.hasOwnProperty('street')) {
record.set('address_street', data.address.street);
}
if (data.hasOwnProperty('address') && data.address.hasOwnProperty('zipCode')) {
record.set('address_zip_code', data.address.zipCode);
}
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
object | Source object (typically the parsed JSON request body). |
|||||||||||||
properties |
Array.<string> | Camel-cased properties of the source object to parse.
The column names will correspond to the underscored names of the properties (e.g. |
|||||||||||||
options |
object |
<optional> |
Deserialization options. Properties
|
Returns:
This record.
- Type
- Model
serializeTo(target, properties, optionsopt) → {object}
- Source:
- Inherited From:
Serializes columns of this record into the specified target object.
// The following code:
record.serializeTo(target, [ 'name', 'site_url' ]);
// Is equivalent to:
if (record.has('name')) {
target.name = record.get('name');
}
if (record.has('site_url')) {
target.siteUrl = record.get('site_url');
}
// The following code:
record.serializeTo(target, [ 'street', 'zip_code' ], { columnPrefix: 'address_', targetPrefix: 'address.' });
// Is equivalent to:
if (!target.hasOwnProperty('address')) {
target.address = {};
}
if (record.has('address_street')) {
target.address.street = record.get('address_street');
}
if (record.has('address_zip_code')) {
target.address.zipCode = record.get('address_zip_code');
}
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
object | Target object to attach serialized properties to. |
|||||||||||||
properties |
Array.<string> | Underscored column names of the record to serialize.
The target property names will correspond to the camelized names of the columns (e.g. |
|||||||||||||
options |
object |
<optional> |
Serialization options. Properties
|
Returns:
The target object.
- Type
- object