0

I'm from following issue.

How to manage add and update data in Firebase

Initially I can make data in firestore following code.

However I would like to add car2 inside of cars after car1. I have no idea of it.

_firestore.collection('members').document(${loginUser.uid}).setData({ 'cars': { 'car1': { 'name': name, 'img_url': 'https://www.xxx.xxx/xxx.png', 'details': { 'type': carType, } } } 

Please give me advice.

1
  • That is my typo. sorry. Commented May 21, 2020 at 8:42

2 Answers 2

2

To add cars2, then do the following:

_firestore.collection('members').document(${loginUser.uid}).updateData({ "cars.car2": { 'name': name, 'img_url': 'https://www.xxx.xxx/xxx.png', 'details': { 'type': carType, } } 
Sign up to request clarification or add additional context in comments.

Comments

0
Firestore.instance.collection(city).document('Attractions').updateData({"data": FieldValue.arrayUnion(obj)}); 

2 Comments

I don't get what obj is. Error comes out.
obj is array(List)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.