gstore-node
v7.x
v7.x
  • Introduction
  • Getting Started
    • Motivation
    • Installation
    • Create a gstore instance
  • Schema
    • About
    • Type validation
    • Value validation
    • Additional properties settings
    • Schema options
    • Joi Schema
    • Methods
      • path()
      • virtual()
    • Custom methods
  • Model
    • Creation
    • Methods
      • GET
      • UPDATE
      • DELETE
      • excludeFromIndexes()
      • key()
      • sanitize()
      • clearCache()
  • Entity
    • Creation
    • Properties
    • Methods
      • SAVE
      • plain()
      • populate()
      • model()
      • datastoreEntity()
      • validate()
  • Queries
    • @google-cloud Query
    • list()
    • findOne()
    • deleteAll()
    • findAround()
  • Populate
  • Middleware (hooks)
    • About
    • Pre hooks
    • Post hooks
  • Cache / Dataloader
    • Dataloader
    • Cache
  • gstore Methods
    • save()
  • Typescript
  • Appendix
    • Error Codes
    • Credits
Powered by GitBook
On this page

Was this helpful?

  1. Entity
  2. Methods

populate()

This methods allows you to fetch all the references entities declared on your Schema.

It accepts two optional arguments:

  • references (string or Array<string>) One or multiple references to fetch (e.g. 'author' or ['author', 'address'])

  • properties (string or Array<string>) The properties to return from the fetched reference entities.

entity.populate('user', 'email')
    .populate('address') // Calls can be chained
    .then(() => {
        // entity.user.email has been fetched
        // entity.address will has been fetched
    });

For a detailed explanation on how populate() works, refer to the documentation.

Previousplain()Nextmodel()

Last updated 6 years ago

Was this helpful?