about summary refs log tree commit diff stats
path: root/src/catalogue.lil
blob: 52d1e60b773a4d1be0dd8d7af554cdeb785131ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# spent a good bit of time playing with lil and reviewing the docs. I am now
# totally smitten and excited to use lil. 

# a basic sketch of the data table at the center of the action

# catalogue.entry_type
# catalogue.parent # not 100% certain how to reference another entry by id
# catalogue.title
# catalogue.body
# catalogue.reference
# catalogue.created_date
# catalogue.updated_date # does this matter? (sorta leaning towards "no")

# entry_type's 
# - link
# - note
# - folder

# every item can have 1 parent
# a parent is usually a folder

# data table wrapped in an interactive cli for adding, querying, and viewing
# input data. Input data stored as CSV between sessions

# NOTE: if input data is stored as CSV is becomes trivial to pipe in and out 
# of SQLite in the future...if that'd be desirable

# NOTE: I'm using just 1 table so that this can be easily exported as CSV...
# if it weren't for that requirement, I'd have multiple tables

catalogue.entry_type:"folder","folder","note","link","link"
catalogue.parent:0,0,0,0,0 # QUESTION: how to reference other entries by IDs
catalogue.title:"read","to read","what an idea","Oatmeal","sans"
catalogue.body:0,0,"what if I made a lil cli",0,0
catalogue.reference:0,0,0,"https://eli.li","https://smallandnearlysilent.com"
catalogue.created_date:"2022-12-07","2022-12-07","2022-12-07","2022-12-07","2022-12-07"
catalogue:table catalogue

# alternate syntax to make a table, 
# t: insert food:("Eggs","Pancakes","Grapefruit") quantity:(3,4,1) tasty:(1,1,0) into 0

# validate that I can write a table to disk and read it back in
show[catalogue]
out:writecsv[catalogue]
show[out]
write["test.csv" out]

data:read["test.csv"]
newtable:readcsv[data "sissss"] # this column spec. syntax looks hilarious
show[newtable]
# HUGE SUCCESS!

# Not sure how to programmatically access/view the implicit ID column...or if that is wise?
# in lieu of using the implicit IDs when referencing a row, I think maybe I'll come up with 
# my own ID and use that instead...a well known ID?

on entry d t do
	t:insert entry_type:(d.entry_type) title:(d.title) into t
end

# where d is a table representing a new row to be added to t, an existing table

row.entry_type:"note"
row.title:"in which we test adding a row with a function"
row:table row
test:entry[row catalogue]

show[test] # NOTE, keep in mind that this generates a totally new table