Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections: should get return an object or an array? #863

Open
josephjclark opened this issue Dec 10, 2024 · 0 comments
Open

Collections: should get return an object or an array? #863

josephjclark opened this issue Dec 10, 2024 · 0 comments

Comments

@josephjclark
Copy link
Collaborator

josephjclark commented Dec 10, 2024

When I do collections.get('collection', '*'), the returned state.data is an array of {key, value} pairs. The array has a cursor key.

Maybe I've just confused myself after doing the CLI, but shouldn't we return an object of keys and values? Ie, { key1: { ... },key2: { ...} }

We'd probably have to nest it in an { items, cursor } object to expose the cursor to the user.

Some considerations:

  • The CLI will output and object of key/value pairs. Surely the adaptor and CLI should use the same structure?
  • each will call the callback with state, value, key. No object.
  • If I return an object, that's a bit harder to iterate over. I can't do state.data.map(({value}) => { ... }). I probably can't pass it into common.each.
  • the {key, value } structure allows us to return metadata, like created and udpated timestamps, ie {key, value, created, updated }. This was actually the initial design and is what the wire format should look like. If we don't use this structure, how do we handle metadata? If we return a flat object there's no space. We'd have to add a non-iteratable meta key or something

Hmm. Maybe we're doing the right thing with the array. I'll think about this overnight.

@github-project-automation github-project-automation bot moved this to New Issues in v2 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New Issues
Development

No branches or pull requests

1 participant