## Properties

$fq
$id

$name
store

## Methods

$addJoin(joinName, joinRecord[, joinFrequency])
$clone()

$delJoin(joinName, joinRecord[, joinFrequency])
toJSON([joinRecords][, joinRecordFields][, sysFields])

## Record()

Records are used for storing data in module:qm.Store.
Factory pattern: this class cannot be construced using the new keyword. This class is constructed when calling a specific method or attribute, e.g. using module:qm.Store#push to create a new record in the store or module:qm.Store#newRecord to create a new record, that is not saved in the store.

## Properties

### $fq

Returns the frequency of the record. Type `number`.

### $id

Returns the id of the record. Type `number`.

### $name

Returns the name of the record. Type `string`.

### store

Returns the store the record belongs to. Type module:qm.Store.

## Methods

### $addJoin(joinName, joinRecord[, joinFrequency]) → module:qm.Record

Adds a join record `joinRecord` to join `joinName` (string) with join frequency `joinFrequency`.

#### Example

    // import qm module
    var qm = require('qminer');
    // Create two stores
    var base = new qm.Base({
        mode: 'createClean',
        schema: [
          { name: 'People',
            fields: [{ name: 'name', type: 'string', primary: true }],
            joins: [{ name: 'directed', 'type': 'index', 'store': 'Movies', 'inverse': 'director' }] },
          { name: 'Movies',
            fields: [{ name: 'title', type: 'string', primary: true }],
            joins: [{ name: 'director', 'type': 'field', 'store': 'People', 'inverse': 'directed' }] }
        ]
    });
    // Add a record to people and a record to movies
    base.store('Movies').push({ title: 'Coffee and Cigarettes' });
    base.store('People').push({ name: 'Jim Jarmusch' });

    // add a join between the added records
    base.store('People')[0].$addJoin('directed', base.store('Movies')[0]);
    base.close();

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
joinName | string |  | Join name.
joinRecord | (module:qm.Record or number) |  | Joined record or its ID.
joinFrequency | number | Yes | Frequency attached to the join. Defaults to `1`.

Returns

  `module:qm.Record`B The joined record.

### $clone() → module:qm.Record

Clones the record.

#### Example

    // import qm module
    var qm = require('qminer');
    // create a new base containing one store
    var base = new qm.Base({
       mode: "createClean",
       schema: [{
           name: "StarWarsMovies",
           fields: [
               { name: "Title", type: "string" },
               { name: "ReleseDate", type: "datetime" },
               { name: "Length", type: "int" }
           ]
       }]
    });
    // create some records in the new store
    base.store("StarWarsMovies").push({ Title: "Attack of the Clones", ReleseDate: "2002-05-16T00:00:00", Length: 142 });
    base.store("StarWarsMovies").push({ Title: "The Empire Strikes Back", ReleseDate: "1980-06-20T00:00:00", Length: 124 });
    base.store("StarWarsMovies").push({ Title: "Return of the Jedi", ReleseDate: "1983-05-25T00:00:00", Length: 134 });
    // create a clone of the "Attack of the Clones" record
    var clone = base.store("StarWarsMovies")[0].$clone();
    base.close();

Returns

  `module:qm.Record`B The clone of the record.

### $delJoin(joinName, joinRecord[, joinFrequency]) → module:qm.Record

Deletes join record `joinRecord` from join `joinName` (string) with join frequency `joinFrequency`.

#### Example

    // import qm module
    var qm = require('qminer');
    // Create two stores
    var base = new qm.Base({
        mode: 'createClean',
        schema: [
          { name: 'People',
            fields: [{ name: 'name', type: 'string', primary: true }],
            joins: [{ name: 'directed', 'type': 'index', 'store': 'Movies', 'inverse': 'director' }] },
          { name: 'Movies',
            fields: [{ name: 'title', type: 'string', primary: true }],
            joins: [{ name: 'director', 'type': 'field', 'store': 'People', 'inverse': 'directed' }] }
        ]
    });
    // Add a record to people and a record to movies
    base.store('Movies').push({ title: 'Coffee and Cigarettes', director: { name: 'Jim Jarmusch' } });
    // delete the join between the added records
    base.store('People')[0].$delJoin('directed', base.store('Movies')[0]);
    base.close();

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
joinName | string |  | Join name.
joinRecord | (module:qm.Record or number) |  | Joined record or its ID.
joinFrequency | number | Yes | Frequency attached to the join. Defaults to `1`.

Returns

  `module:qm.Record`B The joined record.

### toJSON([joinRecords][, joinRecordFields][, sysFields]) → Object

Creates a JSON version of the record.

#### Example

    // import qm module
    var qm = require('qminer');
    // create a new base containing one store
    var base = new qm.Base({
       mode: "createClean",
       schema: [{
           name: "Musicians",
           fields: [
               { name: "Name", type: "string", primary: true },
               { name: "DateOfBirth", type: "datetime" },
               { name: "GreatestHits", type: "string_v" }
           ]
       }]
    });
    // create some records
    base.store("Musicians").push({ Name: "Jimmy Page", DateOfBirth:  "1944-01-09T00:00:00", GreatestHits: ["Stairway to Heaven", "Whole Lotta Love"] });
    base.store("Musicians").push({ Name: "Beyonce", DateOfBirth: "1981-09-04T00:00:00", GreatestHits: ["Single Ladies (Put a Ring on It)"] });
    // get a JSON version of the "Beyonce" record
    // The JSON object for this example si:
    // { '$id': 1, Name: 'Beyonce', ActiveSince: '1981-09-04T00:00:00', GreatestHits: ['Single Ladies (Put a Ring on It)'] }
    var json = base.store("Musicians").recordByName("Beyonce").toJSON();
    base.close();

#### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
joinRecords | Boolean | Yes | Include joined records (only IDs). Defaults to `false`.
joinRecordFields | Boolean | Yes | Expand joined record fields. Defaults to `false`.
sysFields | Boolean | Yes | If set to true system fields, like $id, will be included. Defaults to `true`.

Returns

  `Object`B The JSON version of the record.