Database 颤振:如何为我们想要上传到firebase数据库的每个元素设置数据类型?
我想将一组数据上传到firebase数据库中,并将这些数据设置为特定的数据类型。 在firebase数据库中,我们有字符串、数字、布尔值、映射、数组、null、时间戳、地理点和引用。 如何获取颤振代码来指定数据库元素的类型Database 颤振:如何为我们想要上传到firebase数据库的每个元素设置数据类型?,database,firebase,flutter,dart,types,Database,Firebase,Flutter,Dart,Types,我想将一组数据上传到firebase数据库中,并将这些数据设置为特定的数据类型。 在firebase数据库中,我们有字符串、数字、布尔值、映射、数组、null、时间戳、地理点和引用。 如何获取颤振代码来指定数据库元素的类型 Future database() async { return await userCollection.document(uid).setData({ string : , number : , boolean : ,
Future database() async {
return await userCollection.document(uid).setData({
string : ,
number : ,
boolean : ,
map : ,
array : ,
null : ,
timestamp : ,
geopoint : ,
reference: ,
});
}
将映射作为参数,因此必须执行以下操作:
Future database() async {
return await userCollection.document(uid).setData(
{
"name" : "john",
"age" : 50,
"email" : "example@example.com",
"address" : {
"street" : "street 24",
"city" : "new york"
}
})
这样,您将向数据库添加字符串、整数和映射。将映射作为参数,因此您必须执行以下操作:
Future database() async {
return await userCollection.document(uid).setData(
{
"name" : "john",
"age" : 50,
"email" : "example@example.com",
"address" : {
"street" : "street 24",
"city" : "new york"
}
})
通过这种方式,您将向数据库添加字符串、整数和映射。由于答案帮助您通过单击旁边的复选标记将其标记为正确,谢谢!由于答案帮助您,请单击旁边的复选标记将其标记为正确,谢谢!