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

feat(nodejs): introduce safer timestamp API #21

Merged
merged 3 commits into from
Oct 9, 2023

Conversation

puzpuzpuz
Copy link
Collaborator

@puzpuzpuz puzpuzpuz commented Oct 9, 2023

Note. This is a breaking change, so the patch bumps the version to 2.0.0.

Adds time unit as an optional parameter to timestamp-accepting methods:

  const bday = Date.parse('1856-07-10');
  sender
    .table('inventors')
    .symbol('born', 'Austrian Empire')
    .timestampColumn('birthday', bday, 'ms') // notice 'ms' here
    .intColumn('id', 0)
    .stringColumn('name', 'Nicola Tesla')
    .at(Date.now(), 'ms'); // notice 'ms' here

The unit defaults to 'us' (native QuestDB resolution) in both timestampColumn() and at(). Supported values are:

  • 'ns' - nanoseconds
  • 'us' - microseconds
  • 'ms' - milliseconds

Also, includes some code style changes (e.g. consistent ' instead of mixed ' and ") and a number of improvements, including example unification with the Java client.

Considered alternatives

Temporal types could be used instead of the optional parameter, but the thing is that the spec is still experimental, so it's too early to rely on it.

@puzpuzpuz puzpuzpuz added the enhancement New feature or request label Oct 9, 2023
@puzpuzpuz puzpuzpuz self-assigned this Oct 9, 2023
@puzpuzpuz puzpuzpuz force-pushed the puzpuzpuz_safer_timestamp_api branch from 1181f11 to 7ca5cfb Compare October 9, 2023 07:38
@puzpuzpuz puzpuzpuz changed the title feat(nodejs): safer timestamp API feat(nodejs): introduce safer timestamp API Oct 9, 2023
test/sender.test.js Outdated Show resolved Hide resolved
@puzpuzpuz puzpuzpuz requested a review from glasstiger October 9, 2023 14:54
@glasstiger glasstiger merged commit 828afd1 into main Oct 9, 2023
2 checks passed
@glasstiger glasstiger deleted the puzpuzpuz_safer_timestamp_api branch October 9, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants