N = require '../' class SimpleTree extends N \_simpletree abstract: true @rootId = null SimpleTree.HasOne SimpleTree, \Parent SimpleTree.Create root: true .Then -> SimpleChain.Create parentId: SimpleChain.Fetch root: true # class SimpleChain extends N \_simplechain abstract: true # # @firstId = 0 # @lastId = 0 # # @Push = @_WrapPromise (blob, done) -> # @Create blob # .fail done # .then (newItem) ~> # @Fetch @lastId # .fail done # .then (.nextId = newItem.id; it.Save done) # # SimpleChain.HasOne SimpleChain, \Next # # class DoubleChain extends SimpleChain.Extend \_doublechain abstract: true # # DoubleChain.HasOne DoubleChain, \Prev # Users.Create! # .fail console.error # .then -> it.AddLeft it # .then -> it.Save! # .fail console.error # .then console.log # .then -> Users.Fetch 1 # .fail console.error # .then console.log # SimpleChain = N \_simplechain , abstract: true, schema: # Next: # type: SimpleChain # localKey: 'nextId' # # DoubleChain = SimpleChain.Extend \_doublechain , abstract: true, schema: # Prev: # type: SimpleChain # localKey: 'prevId' # # DoubleCircularChain = DoubleChain.Extend \_doublecircularchain