Read a document

To read a document, you'll need a reference to it. You can directly reference a document by its ID, or you can access the ref property on a snapshot of the document.

const ref = adamite()
  .database()
  .collection("projects")
  .doc("documentId")

Once you have a reference to the document, you can get a snapshot of that document by calling the get method.

const snap = await ref.get();

You can access the document's ID using the id property on the snapshot.

const documentId = snap.id;

You can access the document's data using the data property on the snapshot.

const documentData = snap.data;

And finally, you can access a reference to the document using the ref property on the snapshot.

const documentRef = snap.ref;

Last updated