Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetOption(merge: true) not working #10

Open
mimib00 opened this issue Oct 16, 2021 · 1 comment · May be fixed by #29
Open

SetOption(merge: true) not working #10

mimib00 opened this issue Oct 16, 2021 · 1 comment · May be fixed by #29

Comments

@mimib00
Copy link

mimib00 commented Oct 16, 2021

When i try to add data to existing doc and the SetOption(merge: true) yet it overwrite the doc it doesn't merge it togather

Task task = Task(title: _taskTitle);
String id = "${_getFormatedDay(_taskDate!.day)}-${_taskDate!.day}".trim();
var taskId = db.collection('task').doc().id;
var data = {
taskId: task.toJson()
};
db.collection('tassker').doc(id).set(data, SetOptions(merge: true));

@khaven
Copy link

khaven commented Jul 13, 2023

I've found the same problem.
@override Future<dynamic> set(Map<String, dynamic> data, [SetOptions? options]) async { options ??= SetOptions(); if (options.merge) { final output = Map<String, dynamic>.from(data); Map<String, dynamic>? input = _data[id] ?? {}; print(input); output.updateAll((key, value) { input![key] = value; }); _data[id] = input; } else { _data[id] = data; } _utils.set(_data[id], path); }

Input isn't loaded with old data. It's {} when i reloaded app. So it's not adding new data with old data and overwrites with just new data.

@hi-jin hi-jin linked a pull request Sep 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants