API
start
- deep.nodes(...)
- simple chain.
- deep.nodes(..., ...)
- start with schema.
layers
- .up( ... )
- apply something 'up' on success
- .bottom( ... )
- apply something bottom on success
- .flatten()
- flatten success
- .sheets( ... )
- apply sheets on success
modify
- .set( ... )
- set value by path in success
- .replace( ... )
- replace value(s) by query in success
- .remove( ... )
- remove values by query in success
- .transform( ... )
- transform success
runs
- .run( ... )
- run method or function from success
- .exec( ... )
- run function
queries
- .query( q )
- perfom a query on success
- .breadthFirst( test )
- perfom a breadth first traversal
- .depthFirst( test )
- perform a depth first traversal
navigate
- .each( cb )
- loop through success
- .first()
- keep first in success
- .last()
- keep last in success
- .parent()
- take parent(s) in success
- .val()
- inject deep.utils.nodes.val(success)
tools
- .deepLoad()
- perform a deepLoad on success
- .interpret()
- perform an 'interpret' in success
- .reverse()
- perform a reverse on success
- .sort()
- perform a sort on success
validation
- .validate(schema)
- validate success against schema
relations
Start chain.
deep chain and json-schema
You could associate a schema to object injected in a deep chain.
Simply provide schema as second argument when starting such chain.
deep.nodes({
a:1,
b:true,
c:"hello",
d:{
e:"world"
}
},
{
properties:{
d:{
properties:{
e:{ type:"string", required:true }
}
}
}
})
.validate() // you'll see further what's going on here.
.log();
Layers
up
bottom
flatten
sheets
Modify
set
replace
remove
transform
Runs
run
exec
Queries
query
breadthFirst
depthFirst
Navigate
each
first
last
parent
val
Tools
deepLoad
interpret
reverse
sort
Validation
validate
Relations
mapOn
getRelations
mapRelations
deep.nodes(obj).query(q)...
Chained query call through deep chain.
(for full documentations on chained queries and result management, see deep chain docs)
Perfom a query on current chain success and inject query result (full descriptors of selected properties) as chain success.
Return : a deep chain.
deep.nodes({
a:1,
b:true,
c:"hello",
d:{
e:"world"
}
})
// From root : Select the property 'd' then give me the property 'e' in it
.query("/d/e")
.log('"/d/e" :\n') // 'world'
// From root : give me all property wich is a string
.query("//?_type=string")
.log('\n"//?_type=string" :\n'); // ['hello', 'world']
query & schema
deepjs will try to associate correct sub-schema to selected sub-properties (as it does with direct syntax).
deep.nodes({
a:1,
b:true,
c:"hello",
d:{
e:"world"
}
},
{
properties:{
d:{
properties:{
e:{ type:"string", required:true }
}
}
}
})
.query("/d/e")
.done(function(node){
return node.schema;
})
.log();