Answers for "creating a database with firstore"

0

creating a database with firstore

import 'package:cloud_firestore/cloud_firestore.dart';
// for flutter users get cloud_firestore in your pubspec.yaml file  and import in your file


class DatabaseService {

// creating  a user id for individual users that sign into your app 
  final String uid;
  DatabaseService({this.uid})
  

 final CollectionReference Collection = FirebaseFirestore.instance.collection('Home');
 
 // creating a database for users that is login your app 
 Future updateUserData(String name, String friends, int age) async {
    var data = {
   'name' : name,
   'friends' : friends,
   'age' : age,
   };
   
   return await Collection.doc(uid).set(data);
 }
// or 

 return await brewCollection.doc(uid).setData({
   'name' : name,
   'friends' : friends,
   'age' : age,
     });

}
Posted by: Guest on September-24-2021

Code answers related to "creating a database with firstore"

Code answers related to "Javascript"

Browse Popular Code Answers by Language