-
Notifications
You must be signed in to change notification settings - Fork 0
SimpleRead
James Carnley edited this page Jan 4, 2024
·
5 revisions
SimpleRead proof of concept
Reading from /james/:
lastName property
Newest 10 comments
Single record read: efs.read("/james/", "properties", "lastName"):
efs.read(path, edgeType, "lastName") {
//constants for readability
curFolder = 0 // 0=root
directoryType = 1234
filesType = 5678
nameIndexType = 9384
folderName = parse out "james" from path
jamesNode = getNodeByIndex(curFolder, directoryType , nameIndexType , folderName)
fileNameToGet = func arg of "lastName"
fileNode = getNodeByIndex(jamesNode, filesType, nameIndexType , fileNameToGet)
// for browser, get complex data
propData = readProperties(fileNode)
return { data: propData.data, dataType: propData.dataType, edition: propData.edition }
// for contracts, just get raw bytes
propData = readProperty(fileNode, "data")
return propData
}
Multiple records read: efs.read("/james/", "comments", , 10)
efs.read(path, type, , 10) {
// HERE
//constants for readability
curFolder = 0 // root
directoryType = 1234
commentsType = 16548
nameIndexType = 9384
folderName = parse out "james"
jamesNode = getNodeByIndex(curFolder, directoryType, nameIndexType, folderName)
commentNodes = getNodes(jamesNode, commentsType, , desc, 10)
foreach comment in commentNodes:
returnValues += readProperties(comment)
return returnValues
//e.g.:
{
138123: {
type: 16548,
edition: public,
version: 0,
data: "Hello World",
dataType: "markdownstring",
},
938732: {
type: 16548,
edition: public,
version: 0,
data: "This was interesting",
dataType: "markdownstring",
},
...
}
}