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

CLI API for dat schemas #191

Closed
max-mapper opened this issue Oct 1, 2014 · 0 comments
Closed

CLI API for dat schemas #191

max-mapper opened this issue Oct 1, 2014 · 0 comments

Comments

@max-mapper
Copy link
Collaborator

inspired by a interaction with @ekg today in IRC:

2:56 PM <erikg> dat init; (env)% echo '{"hello": "world"}' | dat import --json
2:56 PM <erikg> % dat cat
2:56 PM <erikg> {"hello":"world","key":"ci0ps81a20000uia4ysz8957b","version":1}
2:57 PM <erikg> % echo '{"hellox":"worldz","key":"ci0ps81a20000uia4ysz8957b","version":2}' | dat import --json
2:57 PM <erikg> % dat cat
2:57 PM <erikg> {"hello":null,"hellox":"worldz","key":"ci0ps81a20000uia4ysz8957b","version":2}
2:57 PM <erikg> what i don't understand is why 'hello' is retained in the object

The reason for this behavior is that dat uses a schema to store data (using Protocol Buffers under the hood). When you write JSON it automatically adds any new keys to the schema. This is a pretty auto-magic process right now. To help demystify this we should add CLI APIs to view and edit the schema.

Strawman proposal:

  • dat schema would print a JSON version of the current protobuf schema
  • dat schema edit would open the schema in the default editor (similar to typing git commit)
  • also possibly dat schema import foo.json to let you supply your own schema from a file. Not sure the exact semantics of this one
  • also maybe we should by default write a message to stderr whenever the schema gets changed, just to make it more visible to the user that there is a schema under the hood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants