Link Search Menu Expand Document

Getting Data

Table of contents

  1. Single Document
  2. All Documents
  3. Sub Collection

Read documents from Google’s Firestore

Single Document

Read single document from collection

Example Usage

const u = await User.collection.get({key: user_key});

console.log(u.name);
console.log(u.key);

Convert model into object

const u = await User.collection.get({key: user_key});
console.log(u.toObject());

All Documents

Read all documents from collection

Example Usage

const userList = await User.collection.fetch();

for (let user of userList){
    console.log(user.id, user.name);
}

Sub Collection

Get child documents from collection

Example Usage

const users = await User.collection.parent(parent_key).fetch();

for (let user of users){
    console.log(user.id, user.name);
}

Copyright © 2019 FireO All rights reserved. Powered by OctaByte