Introduction to using Firestore and new Firestore features in TMS WEB Core v1.7
This article is the first in a 4 part series that will explore the new features available in the TWebFirestoreClientDataSet component in TMS Web Core v1.7. A quick summary of the basic features in the previous version of Firestore ClientDataSet component Here’s a quick introduction for those developers who have not had a chance to use the component so far. TWebFirestoreClientDataSet was introduced in TMS Web Core v1.3 to enable the developers to use Google Firestore as a cloud-hosted, NoSQL database for their web apps. By using this component, you can use a Google Firestore collection as a dataset and get a full CRUD functionality to update it. As you make changes to the dataset, the component updates the Firestore collection behind the scenes. What is more, since the component is a ClientDataSet, you can bind the component to various DB-aware TMS WEB Core UI controls via a TWebDataSource. Here are the steps to use a Firestore collection as a dataset: In order to connect to a Firestore collection, all you have to do is drop a TWebFirestoreClientDataSet component on a form and set a few Firebase properties and CollectionName in it. Then define the dataset fields either in design view or in code and make the component Active. Additionally, you can bind the component to various DB-aware TMS WEB Core UI controls via a TWebDataSource. What you get is a basic App with a CRUD functionality out-of-the-box. A Firestore collection is created automatically as soon as you insert the first record. Any dataset updates you make in code or via the DB-aware controls are automatically sent to Firestore collection by the component. Further, the basic authentication of a Google Sign-In is also available in the component so that you can force the user to Sign-In with Google before the data in the Firestore collection can be accessed. This requires a simple Authentication rule to be set up in the Firestore dashboard. Then all you need to do in the component is switch ON its property SignInIsRequired. It takes care of presenting a Google Sign-In popup as soon as you make the dataset active. Complete details for the above steps are given in the TMSWeb Core Firestore documentation. You will also find a TodoList Demo in the folder “DemoDBBackendFirestore” that demonstrates the above features. Please follow the instructions in the TMS Web Core Firestore documentation to set up and run this Demo. Here is a screenshot of the demo: What you will see in action is a web app that displays the Task records from a Firestore collection called “Tasks” and provides the features to edit the data by means of various DB-aware controls bound to the data source. It also prompts for a Google Sign-In if the user is not signed in. Although the basic demo does a good job of showing the CRUD features, it has some problems in the way its start up logic is coded and there is a reason for it as explained below. The demo expects the end user to enter the API Key and other Firebase parameters The values for these parameters are used to set Firebase properties in the Firestore ClientDataSet after the Open button is clicked The values are remembered in the local storage to be used […]
