cli icon indicating copy to clipboard operation
cli copied to clipboard

New type: scaffold indexed list

Open lumtis opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? Please describe. This is a proposition for a new type under starport s command interface

Some cases require a type that is stored in a way between map and list: an indexed list. For example in a chat module, you would need a list so you can append messages in the chat. However if the chat allows several named channels. Those channels would need to be indexed following the its name. But you still want the append method provided by the list command.

There are currently two way to implement such a structure:

  • Scaffold list, and then modify the store key type to include the index (this is the easiest solution if the index is a simple string, if the index is more complex, we miss the complex index scaffolding capability provided by map)
  • Scaffold map and then implement the append functionality. This is a simplest path if the type has a complex index, although more code must be copied for append and the generated queries are adapted a a simple map

Describe the solution you'd like A new command:

starport s indexed-list
[propositions are welcome]

Or an option for list or map (although I would prefer to make it explicit that the whole logic of the type is different)

starport s list ... --index ...

So we have a list that can receive a complex index like map (or just Index by default). The methods of the keeper are the same as list by they take the indexes as argument. And the CLI interface:

tx create-foo [index...]
tx update-foo [index...] [id]
tx delete-foo [index...] [id]
q show-foo [index...] [id]
q list-foo [index...]

lumtis avatar Jul 13 '21 08:07 lumtis

Closed the initial PR.

We should keep this aside while orm module is shipped in the SDK

lumtis avatar Jul 19 '22 13:07 lumtis

Seems like there isn't a direct need for the proposed data type today. Can revisit as needed.

salmad3 avatar Feb 29 '24 16:02 salmad3