Memory Molecule

Add an in-memory TaffyDB database.

Summary
Memory Molecule
Preference Dialog
CommentsMemory molecule recognizes Comma-Separated Values (CSV) formated files.
Properties
typestring, ( r )
pref.namestring, ( r )
pref.privatebool, ( r, w )
dataSetobject, ( r )
Functions
attach
detach
delete
rename
clone
serialize
save

Preference Dialog

Comments

Memory molecule recognizes Comma-Separated Values (CSV) formated files.  To import csv records into the database, simply drag a csv file from your desktop to your private vault and then drag that file to a droplet.

The first row of the CSV file must be the header fields.  If a field contains a field delimiter, namely the comma, that field must be double quoted.

Once imported, you can use dataSet property of this molecule to access data records.  Example usages include,

  • Filter using the database name and object comparison
// Find all the states with population less than or equal to 5 million
 this.molecule.dataSet({Population:{lte:5}});
// Find California's record by abbreviation
this.molecule.dataSet({State:"CA"});
  • Access data easily
// Maryland state recode
var maryland = this.molecule.dataSet({State:"MD"}).first();
// maryland's population
var population = maryland.Population;
// Get an array of state names
var states = this.molecule.dataSet().select("Name");
// Get an array of distinct state abbreviation
var states = this.molecule.dataSet().distinct("State");
// Apply a function to all the states
this.molecule.dataSet().each(function (r) {
  alert(r.Name + "!");
});
  • Modify data on the fly
// Change Virginia's population
this.molecule.dataSet({State:"VA"}).update({Population:9.3});
// Remove Wisconsin
this.molecule.dataSet({Name:"Wisconsin"}).remove();
// insert a new state
this.molecule.dataSet.insert({"Name":"Georgia","State":"GA","Population":12.4});
  • Save to the cloud
this.molecule.save();

Note: only the owner of this molecule can save (write privilege.)  Furthermore, if you are using someone else’s memory molecule and its private flag is set to true by the owner, you will not be able read its data (no read privilege.)

For More detailed information on how to write queries, please visit this page at TaffyDB web site.

Properties

type

string, ( r )

Type of this molecule, memory.

pref.name

string, ( r )

The scriptable name for this molecule.  This name can be set using rename function dynamically.

pref.private

bool, ( r, w )

Designate this database to be private.  Others will not have read access.  After modifying this flag, you must call save to put it in effect.  Default to false.

dataSet

object, ( r )

Returns a pointer to the internal database.

Functions

attach

attach(droplet);

Attach this molecule to the given droplet.

Parameters

droplet(object) a droplet.

Returns

N/A

detach

detach();

Remove this molecule from its droplet.

Parameters

N/A

Returns

N/A

delete

delete();

Delete this molecule.

Parameters

N/A

Returns

N/A

rename

rename(name);

Rename this molecule.

Parameters

name(string) a new name.

Returns

N/A

clone

clone();

Create a clone of this molecule.

Parameters

N/A

Returns

(object) a molecule.

serialize

serialize();

Serialize this molecule into its JSON representation.

Parameters

N/A

Returns

(string) JSON representation of a molecule.

save

save();

Save database to the cloud.

Parameters

N/A

Returns

N/A

Close