-
Notifications
You must be signed in to change notification settings - Fork 153
Adding Timestamp class #220
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
Conversation
ad115af
to
f9a03ef
Compare
Codecov Report
@@ Coverage Diff @@
## master #220 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 12 13 +1
Lines 1799 1834 +35
=====================================
+ Hits 1799 1834 +35
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the question about truncation. Otherwise LGTM with very small nits.
src/index.js
Outdated
* `Timestamp` instead. | ||
* <br/>NOTE: in the future `timestampsInSnapshots: true` will become the | ||
* default and this option will be removed so you should change your code to | ||
* use Timestamp now and opt-in to this new behavior as soon as you can. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
'use strict'; | ||
|
||
const is = require('is'); | ||
const validate = require('./validate')(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
*/ | ||
isEqual(other) { | ||
return ( | ||
this === other || |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/validate.js
Outdated
return false; | ||
} | ||
if (value < min || value > max) { | ||
throw new Error(`Value must be within [${min}, ${max}] inclusive.`); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
assert.throws(() => { | ||
new Firestore.GeoPoint(); | ||
}, expectedErr); | ||
}, /Argument "latitude" is not a valid number/); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
types/firestore.d.ts
Outdated
* | ||
* NOTE: in the future `timestampsInSnapshots: true` will become the | ||
* default and this option will be removed so you should change your code to | ||
* use Timestamp now and opt-in to this new behavior as soon as you can. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
.then(res => { | ||
const timestamp = res.get('moonLanding'); | ||
assert.equal(timestamp.seconds, -14182920); | ||
assert.equal(timestamp.nanoseconds, 123000123); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
e620cfd
to
2326edb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback addressed. Thanks for your review!
src/index.js
Outdated
* `Timestamp` instead. | ||
* <br/>NOTE: in the future `timestampsInSnapshots: true` will become the | ||
* default and this option will be removed so you should change your code to | ||
* use Timestamp now and opt-in to this new behavior as soon as you can. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
'use strict'; | ||
|
||
const is = require('is'); | ||
const validate = require('./validate')(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
*/ | ||
isEqual(other) { | ||
return ( | ||
this === other || |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/validate.js
Outdated
return false; | ||
} | ||
if (value < min || value > max) { | ||
throw new Error(`Value must be within [${min}, ${max}] inclusive.`); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
assert.throws(() => { | ||
new Firestore.GeoPoint(); | ||
}, expectedErr); | ||
}, /Argument "latitude" is not a valid number/); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
.then(res => { | ||
const timestamp = res.get('moonLanding'); | ||
assert.equal(timestamp.seconds, -14182920); | ||
assert.equal(timestamp.nanoseconds, 123000123); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
types/firestore.d.ts
Outdated
* | ||
* NOTE: in the future `timestampsInSnapshots: true` will become the | ||
* default and this option will be removed so you should change your code to | ||
* use Timestamp now and opt-in to this new behavior as soon as you can. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
2326edb
to
e3d913e
Compare
Adding @stephenplusplus / @JustinBeckwith for approval. FYI: @var-const is a member of the client SDK team. |
/** | ||
* The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. | ||
*/ | ||
readonly seconds: number; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I am using the Admin SDK yes, what release date would you be looking at for this new SDK?
… Op 20 jul. 2018, om 21:06 heeft Sebastian Schmidt ***@***.***> het volgende geschreven:
@schmidt-sebastian commented on this pull request.
In types/firestore.d.ts <#220 (comment)>:
> + * Creates a new timestamp.
+ *
+ * @param seconds The number of seconds of UTC time since Unix epoch
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
+ * 9999-12-31T23:59:59Z inclusive.
+ * @param nanoseconds The non-negative fractions of a second at nanosecond
+ * resolution. Negative second values with fractions must still have
+ * non-negative nanoseconds values that count forward in time. Must be from
+ * 0 to 999,999,999 inclusive.
+ */
+ constructor(seconds: number, nanoseconds: number);
+
+ /**
+ * The number of seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z.
+ */
+ readonly seconds: number;
Hi! Are you using the Admin SDK? If you are using the Admin SDK, you have to use the Admin-exported type of Timestamp (admin.firestore.Timestamp). That, however, is not possible until the next release of the Admin SDK, which will include the definition for this type (as per firebase/firebase-admin-node#309 <firebase/firebase-admin-node#309>).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#220 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ALznB50LR7zYW5eIk8WEZm1Lh1mPLMsbks5uIio6gaJpZM4U2xIK>.
|
@Edalbrelord we can get a patch release out sometime next week. |
This ports the new Timestamp class to Node JS.
Also:
A follow-up PR will use the new Timestamp type in the .createTime, .updateTime and .readTime.