UNPKG

1.23 kBPlain TextView Raw
1N = require '../'
2
3class SimpleTree extends N \_simpletree abstract: true
4
5 @rootId = null
6
7SimpleTree.HasOne SimpleTree, \Parent
8
9SimpleTree.Create root: true .Then -> SimpleChain.Create parentId: SimpleChain.Fetch root: true
10
11
12
13# class SimpleChain extends N \_simplechain abstract: true
14#
15# @firstId = 0
16# @lastId = 0
17#
18# @Push = @_WrapPromise (blob, done) ->
19# @Create blob
20# .fail done
21# .then (newItem) ~>
22# @Fetch @lastId
23# .fail done
24# .then (.nextId = newItem.id; it.Save done)
25#
26# SimpleChain.HasOne SimpleChain, \Next
27#
28# class DoubleChain extends SimpleChain.Extend \_doublechain abstract: true
29#
30# DoubleChain.HasOne DoubleChain, \Prev
31
32
33
34# Users.Create!
35# .fail console.error
36# .then -> it.AddLeft it
37# .then -> it.Save!
38# .fail console.error
39# .then console.log
40# .then -> Users.Fetch 1
41# .fail console.error
42# .then console.log
43
44# SimpleChain = N \_simplechain , abstract: true, schema:
45# Next:
46# type: SimpleChain
47# localKey: 'nextId'
48#
49# DoubleChain = SimpleChain.Extend \_doublechain , abstract: true, schema:
50# Prev:
51# type: SimpleChain
52# localKey: 'prevId'
53#
54# DoubleCircularChain = DoubleChain.Extend \_doublecircularchain