mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated Design: Library Sidebar (markdown)
parent
ff25ee904f
commit
4b8ead76eb
@ -156,10 +156,44 @@ The previous example becomes:
|
||||
|
||||
## Storage API
|
||||
|
||||
The current storage API is not going to change:
|
||||
Ideally the underlying storage api shouldn't have to change. But it needs to.
|
||||
|
||||
The problem is with [`Storage.getLibraryEntry(type,name)`](http://nodered.org/docs/api/storage/methods/#storagegetlibraryentrytypename).
|
||||
|
||||
In its current form, if `name` is a directory, it is expected to return a listing of the files and directories, *including any metadata about the files*. This is a problem as that metadata (such as `outputs` count on Functions) is contained inside the file; in order to return the listing, every file must be read in part to retrieve its metadata.
|
||||
|
||||
We need three functions:
|
||||
|
||||
1. return a listing of all items of a given type
|
||||
2. return the contents of a given type
|
||||
3. save a type
|
||||
|
||||
That means adding a new function that returns the full listing
|
||||
|
||||
#### `Storage.getLibraryEntries(type)`
|
||||
|
||||
_New_: Returns the full listing of the give types in the library in the format described above.
|
||||
|
||||
#### `Storage.getLibraryEntry(type,path)`
|
||||
|
||||
_Changed_: Get a type-specific library entry. Unlike the current version, `path` is expected to be a specific entry - not a directory.
|
||||
|
||||
It will return an object:
|
||||
|
||||
{
|
||||
path: "/full/path/to/the/entryName,
|
||||
name: "entryName"
|
||||
meta: {
|
||||
a: "optional meta data about the entry"
|
||||
},
|
||||
body: "the main body of the entry"
|
||||
}
|
||||
|
||||
|
||||
#### `Storage.saveLibraryEntry(type,name,meta,body)`
|
||||
|
||||
_Unchanged_: save a type-specific library entry
|
||||
|
||||
- [`Storage.getLibraryEntry(type,name)`](http://nodered.org/docs/api/storage/methods/#storagegetlibraryentrytypename)
|
||||
- [`Storage.saveLibraryEntry(type,name,meta,body)`](http://nodered.org/docs/api/storage/methods/#storagesavelibraryentrytypenamemetabody)
|
||||
|
||||
|
||||
---
|
||||
|
Loading…
Reference in New Issue
Block a user