## Property

length

## Methods

push(rec)

save(fout)

## new RecordVector(base[, fin])

Vector of records by value.

### Example

    // import qm module
    var qm = require('qminer');
    // create a new base containing one store
    var base = new qm.Base({
       mode: "createClean",
       schema: [{
           name: "Philosophers",
           fields: [
               { name: "Name", type: "string" },
               { name: "Era", type: "string" }
           ]
       }]
    });
    // Create record vector
    var recordVector = new qm.RecordVector(base);
    // Add some records to the vector
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Plato", Era: "Ancient philosophy" }));
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Immanuel Kant", Era: "18th-century philosophy" }));
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Emmanuel Levinas", Era: "20th-century philosophy" }));
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Rene Descartes", Era: "17th-century philosophy" }));
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Confucius", Era: "Ancient philosophy" }));
    // Iterate over all records
    for (var i = 0; i < recordVector.length; i++) {
       var rec = recordVector[i];
       var tite = rec.Name + " (" + rec.Era + ")";
    }
    base.close();

### Parameters

Name | Type | Optional | Description
--- | --- | --- | ---
base | module:qm.Base |  | Qminer base object.
fin | module:fs.FIn | Yes | Load vector from input stream.

## Property

### length

Gives the number of records. Type `number`.

## Methods

### push(rec) → number

Adds a new record to the vector.

#### Example

    // import qm module
    var qm = require('qminer');
    // create a new base containing one store
    var base = new qm.Base({
       mode: "createClean",
       schema: [{
           name: "Philosophers",
           fields: [
               { name: "Name", type: "string" },
               { name: "Era", type: "string" }
           ]
       }]
    });
    // Create record vector
    var recordVector = new qm.RecordVector(base);
    // Add some records to the vector
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Plato", Era: "Ancient philosophy" }));
    base.close();

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
rec | module:qm.Record |  | The added record. The record must be provided by value.

Returns

  `number`B The position of the added record in the vector.

### save(fout) → module:fs.FOut

Saves the vector into the output stream.

#### Example

    // import qm module
    var qm = require('qminer');
    var fs = require('qminer').fs;
    // create a new base containing one store
    var base = new qm.Base({
       mode: "createClean",
       schema: [{
           name: "Philosophers",
           fields: [
               { name: "Name", type: "string" },
               { name: "Era", type: "string" }
           ]
       }]
    });
    // Create record vector
    var recordVector = new qm.RecordVector(base);
    // Add some records to the vector
    recordVector.push(base.store("Philosophers").newRecord({ Name: "Plato", Era: "Ancient philosophy" }));
    // save to disk
    var fout = fs.openWrite('record_vector.bin');
    recordVector.save(fout).close();
    // load into a new vector
    var fin = fs.openRead('record_vector.bin');
    var recordVector2 = new qm.RecordVector(base, fin);
    base.close();

#### Parameter

Name | Type | Optional | Description
--- | --- | --- | ---
fout | module:fs.FOut |  | Output stream.

Returns

  `module:fs.FOut`B The output stream `fout`.