Twitter LogoFacebook Logo
Firestore - Add Documents
Learning the design flow to add documents to Firestore in FBP
By: King

Hello, in this tutorial, I’ll show you how to add documents to Firestore using the FBP Firebase Plugin for Unreal Engine.

To add documents to Firestore using the FBP Firebase Plugin, 

(1) First, create the document using a series of nodes provided by the plugin
(2) Add the document by using the “Add Document” node

Below is a sample workflow of adding a document.

Image from Codeible.com

Creating the Document

To add a document using the FBP Plugin, you will need to create the document first. To create the document, start with the "Begin Write Document" node.

Image from Codeible.com

To create the document, start with the "Begin Write Document" node.

Then, you can add data to it by calling these available nodes:

(1) Add String
(2) Add Number
(3) Add Boolean
(4) Add String Array
(5) Add Number Array
(6) Add Boolean Array
(7) Add Map

Image from Codeible.com

Adding the document

Once the document is created, use the Add Document node and connect the Document object returned by the last add node to the Document pin.

Then set the location of where to add it using the Document Path pin. Left click on the pin, hold, and drag to an empty space in the blueprint. 

Type "Make" in the Search box and select "Make Array."

Every even element represents a collection, and every odd element represents a document. If no document id is specified, it will generate a unique id.

Image from Codeible.com

If we want to use a specific id, just add another element and provide the id.

Image from Codeible.com

Add the Callbacks

The Add Document function has 2 callback pins used to handle events after the operation is completed.

When the Document is added successfully, it will call the On Document Added callback and when it fails, it will call the On Fail to Add Document callback.

Image from Codeible.com

To create these callbacks, click and hold on the callback pin from the node. Then drag and let go on an empty spot on the blueprint.

Select “Add Event” then “Add Custom Event.” That will create the event node fit for the callback.

Image from Codeible.com

Sign In