Back

How to set Map<String,dynamic> type attribute

  • 0
  • Flutter
Khushal@2303
19 May, 2023, 05:01

I want to store date like "key":"value" pair in the collection. How I can do that?

TL;DR
User is asking how to set a `Map<String,dynamic>` attribute in their code. They are migrating from Firebase and finding it confusing. They want to know if they should create a collection for different tasks or have one collection for all tasks. There is a suggestion to use a JSON string to store the attribute. The user is also looking for help on storing key-value pairs in a collection. Solution: The user can create a collection for different tasks or use a JSON string to store the attribute. Storing key-value pairs in a collection can be done using a `Map<String,dynamic>` attribute.
Drake
19 May, 2023, 05:50
Khushal@2303
19 May, 2023, 06:04

There is no option to select Map DataType attribute

Drake
19 May, 2023, 06:18

Oh...typically, if you're trying to store another object, you would create another collection. If you really don't want to, you can store a JSON string

Xalba
13 Oct, 2023, 03:41

Out of the two what is the best way to do it?

Drake
13 Oct, 2023, 03:42

Typically, a collection

Xalba
13 Oct, 2023, 03:43

Great, thank you

Xalba
13 Oct, 2023, 04:02

I am migrating from firebase and it seems a bit confusing, beacuse with firebase can create nested maps easily within a document.

For example lets say I have a simple model class

class Employee { List<Task> tasks; }

Each employee will have a different set of tasks. So for this, should I create a collection called "tasks" with all the different tasks or create different collection for each employee like, tasksForEmployeeOne, tasksForEmployeeTwo, etc.. ?.

Also no two tasks will be the same.

Drake
13 Oct, 2023, 04:07

That's because firebase is a NoSQL database. Appwrite is much more like a relationship database so researching relational databases would be more relevant

Xalba
13 Oct, 2023, 04:09

Oh okay, I think read somewhere it is NoSql, never mind. Thank you

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more