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

Allow use of $date (EJSON wrapper) for API Table timestamp values (similar to Collections) #1586

Open
tatu-at-datastax opened this issue Oct 22, 2024 · 2 comments
Assignees

Comments

@tatu-at-datastax
Copy link
Contributor

tatu-at-datastax commented Oct 22, 2024

Currently (v1.0.18) API Table columns of type timestamp accept and produce JSON String values (using ISO-8601 encoding). This is different from Collections where EJSON-wrapping with numeric timestamp like:

{ "$date" : 123005946 }

is accepted and produced.

Questions: should we use or allow EJSON-wrapped values for API Tables as well? There are couple of questions to decide:

  1. Should we accept both notations ("plain" String and EJsonWrapper) or just one -- and if so, which one?
  2. If both are accepted, which one should be produced (returned with "findXxx" commands (if only one accepted that'd be one produced too)
  3. If EJSON-wrapped value accepted, should it accept numeric Timestamp (like Collections), or ISO-8601 String (like current API Table).

These decisions should be based on what makes most sense from client perspective: since API Tables not yet externally released we can still change the notation/representation to use.

EDIT:

Answers: we will work to maximize interoperability with Collections.

  1. Should accept BOTH, for interoperability with Collections (so yes accept ALSO EJSON-wrapped values)
  2. Return "plain" ISO-8601 String representation (same as now, no change)
  3. Accept Timestamp (seconds since Epoch, Java long), same as with Collections, for interoperability.
@tatu-at-datastax tatu-at-datastax self-assigned this Oct 22, 2024
@vkarpov15
Copy link
Collaborator

Allowing { $date: 123456 } would make things a little easier for stargate-mongoose, because that's how stargate-mongoose serializes dates currently: https://github.com/stargate/stargate-mongoose/blob/1713dc9206c5891742aa1fdbf71ea7420a81d003/src/client/serialize.ts#L59-L62.

Someday stargate-mongoose may need a "am I talking to a table or a collection?" option, but it would be great to avoid that if possible. Supporting { $date } would mean we can do dates without knowing table or collection.

@tatu-at-datastax
Copy link
Contributor Author

@vkarpov15 That's the idea indeed! Thank you for confirming that the change makes sense. I hope to tackle this issue soon.

@tatu-at-datastax tatu-at-datastax changed the title Consider using/allowing $date (EJSON wrapper) for API Table timestamp values Allow use of $date (EJSON wrapper) for API Table timestamp values (similar to Collections) Oct 24, 2024
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