📜  使用 firstore 创建数据库 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:52.106000             🧑  作者: Mango

代码示例1
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,
     });

}