如何在Firebase实时数据库上创建更多子项

huangapple go评论59阅读模式
英文:

How to create more children on Firebase Realtime Database

问题

我想在Firebase实时数据库上创建更多的子项。

期望效果(示例):[如何在Firebase实时数据库上创建更多子项

我现在拥有的代码如下:

MyButton(
  label: "创建Ride",
  onTap: () {
    ref
        .child('Database')
        .push()
        .child('Title')
        .set(_titleController.text)//Title Controller只是您输入的数据
        .asStream();
    _titleController.clear();
  }),

我找不到任何示例,也不知道如何编写代码,以便不仅仅是一个标题。

英文:

I want to create more children on the Firebase Realtime Database.
Desired effect (example): [如何在Firebase实时数据库上创建更多子项

What I have:

 MyButton(
  label: "Create Ride",
  onTap: () {
    ref
        .child('Database')
        .push()
        .child('Title')
        .set(_titleController.text)//the Title Controller is just the 
                                           //data you type in
        .asStream();
    _titleController.clear();
  }),

I can't find a sample anywhere and I don't know how to write it so that there's more than just a title.

答案1

得分: 0

如果您想在新子节点下写入多个数值,可以这样做:

ref
    .child('Database')
    .push()
    .set({
      'Title': _titleController.text,
      'land': 'Germany',
      'stadt': 'Berlin'
    })

还可以在Firebase文档的写入数据部分看到示例。

英文:

If you want to write multiple values under the new child, you can do:

ref
    .child('Database')
    .push()
    .set({
      'Title': _titleController.text,
      'land': 'Germany',
      'stadt': 'Berlin'
    })

Also see the example in the Firebase documentation on writing data.

huangapple
  • 本文由 发表于 2023年2月19日 02:43:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/75495579.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定