var jsonData = {
    company: {
        name: "ABC",
        people: [
            {name: "John", age:26, gender:"male"},
            {name: "Steve", age:24, gender:"male"},
            {name: "Susan", age:22, gender:"female"},
            {name: "Linda", age:30, gender:"female"},
            {name: "Adam", age:32, gender:"male"}

var peopleStore = new DataStore(jsonData, { dataNode: "company.people" });


  • setConfig(options) – This method allows you to set configuration options of your DataStore instance after it has been instantiated. It takes the same exact arguments as constructor.
  • getRows([start, [end]]) – This method returns all or limited set of rows in your dataset.
  • getRowByIndex(index) – Returns a single row by index. Note: Indexes in the rows remain the same regardless the sort, they are assigned during the data fill.
  • sort(column | [columnDef, n]) – sorts your data. If you just specify a string column name, then the data will be sorted by that column in Asending order. You may specify a multi-column sort as well, in that case you will need to provide columnDef objects as arguments.
    • columnDef – Column definition object
      • column – String column name
      • order – String “asc” | “desc”
      • type – String “text” | “number” | “date”. Default: “text”.
  • getPage(page [, pageSize]) – Returns a page subset (if pagination is enabled). pageSize argument takes preidence over pageSize option set at initialization.
  • count() – Returns a row count.
  • filter(expression) – Returns your rows based on filter expression. Expressions follow jPath syntax similar to XPATH but with a hint of JavaScript in it. Ex. “*[field=value]” will match rows where field equals value.
  • select(expression) – Returns results of jPath expression as new DataStore object. Similar to filter() method but returns a new DataStore instead of the Array.
  • insertRow(row) – Inserts a row object into existing dataset. Row could be an Array or JSON object, just try to keep the structure consistent!
  • sum( column ) – This is an aggregate function that will Sum up all the values in the column (if they are numeric of course). Column argument could be either a String name or a numeric column Index.
  • avg( column ) – Returns an Average for all column values. Same argument options as above (sum).
  • max( column ) – Returns a Maximum number among all values in the column.
  • min( column ) – Returns a Minimum number among all values in the column.
  • unique( column ) – This is a very powerful function that returns a unique set of values for a given column. Column attribute follows the same properties as above – either column name or index.
  • concat( data [, data] ) – As the name implies, this method will concatenate data from another DataStore instance or a Multi-dimensional Array into existing DataStore. This method is very useful when you have two instances of DataStore objects that contain similarly structured data, and you want to work against a merged set to either filter or paginate or find uniques, etc.
  • adjustData( [field], cb ) – This method is used to sanitize data. It executes a callback for each row. There are two signatures to this method:
    • field, cb – If you call adjustData with optional field argument, then it will call callback only for a single field and will pass into callback current value and row reference
    • cb – If you call adjustData only with a callback, then a callback will be called for each row in the dataset and a callback will only receive a row reference as an argument.
  • join(sourceData, pkFk, options) – Very powerful feature that allows you to merge two DataStore’s based on pk->fk relationship. This method supports JOIN operations similar to SQL.
    • sourceData – Another instance of DataStore to merge exsiting DataStore with
    • pkFk – String or Object. If used as String, it implies that both PrimaryKey(PK) and ForeignKey(FK) are named exactly the same. In case PK and FK are named differently, you will need to pass in a mapping object that looks like this: { “destinationKey”:”sourceKey” }.
    • options – Configuration options
      • type – Types of Join: inner(both keys match), differential(only non-matching), left(destination biased), right(source biased). Default: inner.
      • whiteList – Array of source field names that are allowed to be merged w/ destination row
      • blackList – Array of source field names that will be excluded when merging w/ destination row
  • groupBy( column [,column, column …]) – Groups data by a column specified, creating a tree-like structure where keys are unique column values and leafs are rows of data. Each column you specify in the arguments will be nested inside of the previous column group.
  • clone() – Returns a cloned copy of your DataStore.
  • top(n) – Returns a new DataStore which contains a cropped data set of TOP rows specified by n.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s