Class: Collection

Defined in: src\collection.coffee

Variables Summary

name =
""
data =
[]
schema =
{}
errors =
null
observing =
false

Instance Method Summary

Constructor Details

# (void) constructor(name, data = [], schema = {})

Constructs a new collection

Parameters:

  • name ( String ) name of collection

Options Hash: (data):

  • data ( Array ) data to attach to collection

Options Hash: (schema):

  • schema ( Object ) JSON Schema to attach to collection

Instance Method Details

# (void) attach_data(data = [])

Attaches data to the collection instance

Parameters:

  • data ( Array, Object ) data to attach

Options Hash: (data):

  • data ( Array ) if array, push each element
  • data ( Object ) if object, push the object

# (void) attach_schema(schema = {})

Note: see json-schema.org for JSON Schema

Attaches a JSON Schema to the collection instance

Parameters:

  • schema ( Object ) JSON Schema Object to attach to collection

# (String) errors_to_string()

returns errors to a string format if any

Returns:

  • ( String ) — A string of errors, using JSON.stringify

# (Boolean) is_valid()

Note: if no schema provided, it will return true
Note: it uses jjv to do the Schema validation

check to see if the schema is valid

Returns:

  • ( Boolean ) — returns true or false if the schema is valid

# (String) join(a, b)

joines two or more paths together

Examples:

join two paths

var c = new Collection("my_coll").join("path","name"); // "path.name"

join three paths

var c = new Collection("my_coll").join("path","name","[0]"); // "path.name[0]"

Parameters:

  • a ( String ) first string to join
  • b ( String ) second string to join

Returns:

  • ( String ) — A string of a JSON PATH

# (mixed) findByPath(path)

Does a deep search and returns the object if found or else undefined

Examples:

Find name of a person

new Collection("person",{name: "valtid"}).findByPath("[0].name");//"valtid"

Parameters:

  • path ( String ) a JSON path to search for

Returns:

  • ( mixed ) — returns different types of undefined if nothing found

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: