question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use FieldValue.serverTimestamp() from @firebase/firestore-types

See original GitHub issue

Version info

Angular: 5.2.8 Firebase: 4.11.0 AngularFire: 5.0.0-rc.6 Other (e.g. Ionic/Cordova, Node, browser, operating system): Stackblitz - chrome

How to reproduce these conditions

Open the stackblitz Failing test unit, Plunkr, or JSFiddle demonstrating the problem https://stackblitz.com/edit/angular-lrgmmu

Steps to set up and reproduce Open stackblitz

Sample data and security rules none and allow all

Debug output

Can't find module:
@firebase/firestore-types/index (@0.2.2)

Check your import statements & ensure you're importing the correct module names.

** Errors in the JavaScript console ** none

** Output from firebase.database().enableLogging(true); ** none

Expected behavior

Is this not how you should use FieldValue.serverTimestamp() from ‘@firebase/firestore-types’ - or maybe I am misunderstood something?

The server datetime being saved

Actual behavior

I get this error: Can’t find module: @firebase/firestore-types/index (@0.2.2)

Check your import statements & ensure you’re importing the correct module names.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
davideastcommented, Mar 21, 2018

The -types packages are just types and will not work as runtime values. Use the @firebase/app module instead.

import { firebase } from '@firebase/app';

colRef.doc('testDoc').set({
      name: 'testValue',
      // This line works
      lastEdit: firebase.firestore.FieldValue.serverTimestamp(),
      // Should the following line not work?
      anotherEdit: firebase.firestore.FieldValue.serverTimestamp(),
      }, {merge: true})
1reaction
sarunintcommented, Mar 28, 2018

@dauledk You don’t need to install the @firebase/* ones since they are declared as dependencies of firebase already.

See https://unpkg.com/firebase@4.12.0/package.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase: Store server timestamp when document created
Here's how to use Firestore's timestamp (Updated on Feb 2019): ... firebase.firestore.FieldValue.serverTimestamp() is no longer valid.
Read more >
The secrets of Firestore's FieldValue.serverTimestamp()
Everything you need to know about Firestore server timestamps, including writes, queries, security rules, and time travel safety tips.
Read more >
FieldValue | JavaScript SDK | Firebase JavaScript API reference
serverTimestamp ( ) : FieldValue. Returns a sentinel used with set() or update() to include a server-generated timestamp in the written data.
Read more >
write server timestamp as number to firestore - Google Groups
In summary, I read document A from two different API's and get back two different types for the same timestamp field. While i...
Read more >
Adding data | Firestore - Google Cloud
Set a document. To create or overwrite a single document, use the following language-specific set() methods:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found