Properties

Method

Iterator()

Store Iterators allows you to iterate through the records in the store.
Factory pattern: this class cannot be construced using the new keyword. It is constructed by calling a specific method or attribute, e.g. calling module:qm.Store#forwardIter to construct the Iterator.

Example

// import qm module
qm = require('qminer');
// create a new base with a simple store
var base = new qm.Base({ mode: "createClean" });
base.createStore({
    name: "People",
    fields: [
        { name: "Name", type: "string" },
        { name: "Gender", type: "string" }
    ]
});
// add new records to the store
base.store("People").push({ Name: "Geronimo", Gender: "Male" });
base.store("People").push({ Name: "Pochahontas", Gender: "Female" });
base.store("People").push({ Name: "John Rolfe", Gender: "Male" });
base.store("People").push({ Name: "John Smith", Gender: "Male"});
// factory based construction with forwardIter
var iter = base.store("People").forwardIter;
base.close();

Properties

record

Gives the current record. Type module:qm.Record.

store

Gives the store of the iterator. Type module:qm.Store.

Method

next() → boolean

Moves to the next 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: "TheWitcherSaga",
       fields: [
           { name: "Title", type: "string" },
           { name: "YearOfRelease", type: "int" },
           { name: "EnglishEdition", type: "bool" }
       ]
   }]
});
// put some records in the store
base.store("TheWitcherSaga").push({ Title: "Blood of Elves", YearOfRelease: 1994, EnglishEdition: true });
base.store("TheWitcherSaga").push({ Title: "Time of Contempt", YearOfRelease: 1995, EnglishEdition: true });
base.store("TheWitcherSaga").push({ Title: "Baptism of Fire", YearOfRelease: 1996, EnglishEdition: true });
base.store("TheWitcherSaga").push({ Title: "The Swallow's Tower", YearOfRelease: 1997, EnglishEdition: false });
base.store("TheWitcherSaga").push({ Title: "Lady of the Lake", YearOfRelease: 1999, EnglishEdition: false });
base.store("TheWitcherSaga").push({ Title: "Season of Storms", YearOfRelease: 2013, EnglishEdition: false });
// create an iterator for the store
var iter = base.store("TheWitcherSaga").forwardIter;
// go to the first record in the store
iter.next(); // returns true
base.close();
Returns

booleanB
1. True, if the iteration successfully moves to the next record.
2. False, if there is no record left.