Cloud Functions on Firestore for Flutter - firebase

I'm relatively new to Firestore and I am currently trying to build a Flutter app on it. I have hit a roadblock where I realize that I must utilized Firestore Cloud Functions in order to perform server-side data manipulation.
Unfortunately, there are not a lot of great resources and videos describing the process to set this up (at least for someone super new to software development like me). However, I was able to find this video https://www.youtube.com/watch?v=DYfP-UIKxH0 that goes over how to set up a Firestore app using Typscript. As such, I have two questions:
Will setting up the environment to write cloud functions be the same here for Firestore as it will be for Firebase?
Do I want to write these functions in Javascript or Typescript?

Yes. When you use Cloud Firestore, you're essentially using Firebase, and the setup for Cloud Functions is the same between them. If you run into problems, post a questions with the minimal steps needed to reproduce that problem.
That's your call, as recommending one technology over another is off-topic here on Stack Overflow. That said, most developers coming from a background with strictly typed languages may prefer typescript.

Related

How to run different cloud functions for seperate apps in the same Firebase project?

For example, if I wanted to use the functions.auth.user().onUserCreate() trigger, is there any way to make it trigger different functions for different apps that are all in the same Firebase project? Is the only way to fix this to create separate Firebase projects for each app? The issue with that is that I need them to access the same database.
It's not possible to know in a Cloud Functions trigger which app a user used when they created their account. Firebase Auth accounts don't have a sense of "ownership" with respect to multiple apps per project. All apps in a project share the same users with the same permissions.
What you can do instead is have each app write something unique in your database after the account was created, then use that to determine what that user should do later on. Either that, or use different projects if your apps don't actually need to share the same set of users.
The only possibility that I think that might help you is organizing your Cloud Functions in different files, which will be then loaded per project. So, for example, in your Project Alpha, it will run the Cloud Functions from the foo.js file, while in the Project Beta, it will run the functions from the bar.js and the same logic for other projects and Cloud Functions.
This way, even though all users are sharing the same database, it will trigger the function based in the file that you requiring in your application. You can check for tips in organizing your Cloud Functions in multiple files and calling them individually, in this official documentation here:
Organize Functions
I believe this way might work for you, so, I would recommend you to check the documentation and give it a try splitting the functions in multiple files and calling each specific files, on their specific applications only.
Let me know if the information helped you!

Firebase Cloud Firestore "Request/response" documentation

Most of "bigger" project I was working with was using REST API for Frontend->Backend communication. I was using Firebase Cloud Firestore for some small (one-day/hackathon) projects. Now I'm thinking about using Firestore for some bigger project but I'm not sure if this will work.
For "standard", REST api project I had Swagger documentation, where each developer could see list of all endpoints with request/response data structures. How does it work with Firestore? Can I create similar documentation for developers to check data structure, so they will know what can they add and what should they read? Or maybe there is another way?
I'm thinking, maybe there is no tool for this kind of documentation because frontend data structures are defining database structure? But what if I am connecting database from two or more platform (ex. web, mobile and cloud functions)? How can I synchronize knowledge about data structures between all the developers?
I was looking for some answers but couldn't find anything useful expect advice to manually maintain some documentation. How does it work in your projects? Is there some automation? Manually written documentation? Or no documentation - everything "in code"?
I understand your concerns, but unfortunately, there is no such tool available for Cloud Firestore to generate the documentation for database structure as Swagger.
I believe you can do it programatically.
From
Generating Swagger Docs in Firebase Cloud Functions project
I'm using express and nodejs in my Firebase Function implementations, and for me, Swagger doc generation can be implemented via the following libraries:.
https://github.com/scottie1984/swagger-ui-express
https://github.com/Surnet/swagger-jsdoc
You can find other libraries at:
https://swagger.io/tools/open-source/open-source-integrations
In addition to the responses there, the following service allows you to access Firestore metadata, click the explorer tab, looks promising for your use case https://aapi.io/api-directory/Google_CloudFirestore_GoogleCloudFirestoreAPI_v1beta1 though not necessarily more so than the links above.

Is there any way to use Content Based Recommendation using flutter as frontend and firebase as backend?

I am developing a question answering system app like quora, I want to add content based recommendation to my app so that it can give suggestion while searching question based on users previous seen data and also use the recommendation system for showing the similar content at home page!
Well, there's no direct way and Firebase don't have any packages for recommendation system but what you can do is use tensor flow to build your own model, train it and integrate it in to firebase ML which also use the firebase cloud function feature. That's it, now use firebase cloud function in your flutter project.

How to use Google App Engine in conjunction with Firebase

I've been using Firebase for a long time and it's great, however I need more power for certain things.
At the moment, I have a function in Cloud Functions for Firebase to do some video processing and I need more power. I have heard Google's App Engine is better for this kind of solution and I've been experimenting with App Engine with my Google Cloud project.
I went to deploy my first Node.JS app function to App Engine and it seemed as if it was going to overwrite my existing functions I have. I have lots of functions, and code in Firebase for my app and my website to talk to one another, so I'd like to keep and leave my Firebase stuff alone.
I'm just wondering, how I'd use App Engine (and maybe some other higher end Google Cloud products) alongside Firebase without interfering or changing one another, but using the same project?
App Engine is an entirely different product than Cloud Functions. Anything you deploy to App Engine will not affect what you've already deployed to Cloud Functions, and the same applies in reverse. You can use both products in tandem with no conflicts.
Here, you can find more details related to the serverless environments options that you have. It would be helpful to read about each of them and choose whatever fits your needs better.

Using Firebase from google instead of react-native-firebase

At the moment I am using react-native-firebase 4.3.8, but I noticed that google has updated firebase (firestore in particular), which holds some interesting new features. I was trying to use firebase from google directly, but it gives me errors (can't find variable: document) for example.
Is it possible to use firebase instead of react-native-firebase, so the updated features are available.
I know that react-native-firebase are working on an update (v5) to include those features.
To use Firebase within your React Native application you need to bind the JavaScript code to the underlying native iOS/Android SDK. When you use Invertase's react-native-firebase library they take care of that for you.
You can definitely use another library that does the same, or roll your own. But recommending a library is off-topic on Stack Overflow, and showing you how to do this yourself is a bit too broad for a question here.
If you're having problems getting the Invertase library to work, it is best if you share the minimal code that reproduces where you are stuck. That way we can see what you tried, and help you get unstuck.
If none of these apply, you will have to wait until the feature you want it available in the library. Note that Invertase's react-native-firebase library is open source, so they might be taking pull requests in case you want to help.

Resources