Jungles Data
If you are thinking of creating your own data layer for jungles you can use this module to test it.
var dal = ;var test = ; // The test expect this data for each test. var { var boards = type: 'category' path: '/boards' name: 'Boards' sort: 0 color: 'red' order: 0 ; var blades = type: 'category' path: '/blades' name: 'Blades' sort: 1 color: 'blue' order: 1 ; var skateboard = type: 'product' path: '/boards/skateboard' name: 'Skateboard' sort: 0 0 order: 0 ; var wheel = type: 'part' path: '/boards/skateboard/wheel' name: 'Wheel' sort: 0 0 0 order: 0 ; return boards skateboard wheel blades;}; var settings = bail: true // bail tests after one failure. { database; } // reset your database before each test. ;
API
The data layer supports the following methods.
data;data;data;data;data;
Query object
id: 5 // Integer name: 'home' // String path: /.*/ // Regex path: /.*/ id: 5 // path (Regex) AND id (Integer)
Find
var result = data; result; result; result; result;
Remove
var result = data;result;result;
Create
var result = data; result; result;
Update
var result = data; result; result;
Update is lazy if you don't specify certain values it will keep the old ones. If you update an instance with children the children will update as well if path or order changes.
Move
Move is done with data.update
when you provide a parent.
Copy
var result = data; result; result; This will copy the instance and all it's children.
Tree
var result = data; result;result;
Structure
id: 1 name: 'snowboard' path: '/snowboard' type: 'product' sort: 0 children: id: 2 name: 'tags' path: '/snowboard/tags' type: 'tags' sort: 0 0 children: id: 3 name: 'red' path: '/snowboard/tags/red' type: 'tag' sort: 0 0 0