examples/quickstart3.js
function databaseInitialize() {
  var entries = db.getCollection("entries");
  var messages = db.getCollection("messages");

  // Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db'
  // file will actually contain only the loki database shell and each of the collections
  // will be saved into independent 'partition' files with numeric suffix.
  
  // Add our main example collection if this is first run.
  // This collection will save into a partition named quickstart3.db.0 (collection 0)  
  if (entries === null) {
    // first time run so add and configure collection with some arbitrary options
    entries = db.addCollection("entries", { indices: ['x'], clone: true });
  }

  // Now let's add a second collection only to prove that this saved partition (quickstart3.db.1) 
  // doesn't need to be saved every time the other partitions do if it never gets any changes
  // which need to be saved.  The first time we run this should be the only time we save it.
  if (messages === null) {
    messages = db.addCollection("messages");
    messages.insert({ txt: "i will only insert into this collection during databaseInitialize" });
  }

  // kick off any program logic or start listening to external events
  runProgramLogic();
}
function databaseInitialize() {
  var entries = db.getCollection("entries");
  var messages = db.getCollection("messages");

  // Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db'
  // file will actually contain only the loki database shell and each of the collections
  // will be saved into independent 'partition' files with numeric suffix.
  
  // Add our main example collection if this is first run.
  // This collection will save into a partition named quickstart3.db.0 (collection 0)  
  if (entries === null) {
    // first time run so add and configure collection with some arbitrary options
    entries = db.addCollection("entries", { indices: ['x'], clone: true });
  }

  // Now let's add a second collection only to prove that this saved partition (quickstart3.db.1) 
  // doesn't need to be saved every time the other partitions do if it never gets any changes
  // which need to be saved.  The first time we run this should be the only time we save it.
  if (messages === null) {
    messages = db.addCollection("messages");
    messages.insert({ txt: "i will only insert into this collection during databaseInitialize" });
  }

  // kick off any program logic or start listening to external events
  runProgramLogic();
}
function databaseInitialize ( ) { var entries = db . getCollection ( "entries" ) ; var messages = db . getCollection ( "messages" ) ; // Since our LokiFsStructuredAdapter is partitioned, the default 'quickstart3.db' // file will actually contain only the loki database shell and each of the collections // will be saved into independent 'partition' files with numeric suffix. // Add our main example collection if this is first run. // This collection will save into a partition named quickstart3.db.0 (collection 0)   if ( entries === null ) { // first time run so add and configure collection with some arbitrary options entries = db . addCollection ( "entries" , { indices : [ 'x' ] , clone : true } ) ; } // Now let's add a second collection only to prove that this saved partition (quickstart3.db.1)  // doesn't need to be saved every time the other partitions do if it never gets any changes // which need to be saved.  The first time we run this should be the only time we save it. if ( messages === null ) { messages = db . addCollection ( "messages" ) ; messages . insert ( { txt : "i will only insert into this collection during databaseInitialize" } ) ; } // kick off any program logic or start listening to external events runProgramLogic ( ) ; }
Now let's implement the autoload callback referenced in loki constructor
Now let s implement the autoload callback referenced in loki constructor