Back

Can't we add attributes dynamically while creating a document in a specific Collection?

  • 0
  • Databases
  • Web
RohitRanjan
12 Jun, 2023, 06:06

You need to use server sdk to add attributes dynamically

TL;DR
The user wants to know if it's possible to add attributes dynamically while creating a document in a specific collection. They receive various responses and suggestions, including using JSON.stringify, creating a big string attribute, using a NoSQL database, and creating general attributes for specific use cases. One user suggests using the Appwrite server SDK or Appwrite functions. The solution is to use the server SDK to add attributes dynamically.
Sandeep K. Dasari
12 Jun, 2023, 06:08

You mean, While creating the document, we have to use Server side sdk to add the data right?

Sandeep K. Dasari
12 Jun, 2023, 06:09

You mean, we have to create a document using Server side sdk using Appwrite Functions right?

RohitRanjan
12 Jun, 2023, 06:12

Yes you can use Appwrite functions, you can achieve that even without functions

RohitRanjan
12 Jun, 2023, 06:13

https://appwrite.io/docs/getting-started-for-server

Follow this on how you can create database, colections, attributes etc

Sandeep K. Dasari
12 Jun, 2023, 06:17

Thanks Man

Sandeep K. Dasari
12 Jun, 2023, 06:17

Thanks πŸ™‚

Sandeep K. Dasari
12 Jun, 2023, 06:17

[SOLVED]Can't we add attributes dynamically while creating a document in a specific Collection?

Sandeep K. Dasari
12 Jun, 2023, 06:42

brother, Can I add 4 attributes in of document and 15 attributes in second document. I mean, can I add like this using server SDK?

Sandeep K. Dasari
12 Jun, 2023, 06:42

I mean, Can I add Multiple and different attributes in different documents in the same COLLECTION?

Sandeep K. Dasari
12 Jun, 2023, 06:43

@RohitRanjan In a typical Collection, If one document contains 10 different attributes, another document in the same collection could contain 15 different attributes.

Sandeep K. Dasari
12 Jun, 2023, 06:44

Can I achieve this use case using appwrite server SDK? in the client side using functions?

Sandeep K. Dasari
12 Jun, 2023, 06:44

I dont want to create seperate server .

Sandeep K. Dasari
12 Jun, 2023, 06:55

Can't we add attributes dynamically while creating a document in a specific Collection?

Sandeep K. Dasari
12 Jun, 2023, 10:41

Could Anyone please respond 😦

Binyamin
12 Jun, 2023, 12:41

Your use-case is common and generally very easy todo with NoSQL database. Appwrite's actually MariaDB, which is relational DB.

If I was you I probably won't create the attribute on the fly as it can get crowded real fast. What I suggest is to create the general attributes, for example, for your form case.

  • form
  • userID
  • ... other indexable and searchable fields.
  • json

Then inside the json I'll put everything as a json inside a big string attribute.

Also, you can go - I'm not a big fan - into EAV solution - like magento - check about it here. https://www.oscprofessionals.com/blog/understanding-different-layers-of-magento-module-development/

Sandeep K. Dasari
12 Jun, 2023, 14:30

@Binyamin The maximum size is so less, We have to mention the size of the string while uploading it right! So, If it won't be suffice, We can get into trouble right?

Binyamin
12 Jun, 2023, 14:32

The maximum size is so less What you mean? of the string attribute?

You can create a very big attribute as you can see here: https://discord.com/channels/564160730845151244/1116054662999724134/1116057738187919551

Sandeep K. Dasari
12 Jun, 2023, 14:33

If we use, So set it to 16777216 to have unlimited one , this size, Will it be unlimited?

Binyamin
12 Jun, 2023, 14:34

Up to MariaDB limits.

Sandeep K. Dasari
12 Jun, 2023, 14:34

Okay alright, Is it okay

Sandeep K. Dasari
12 Jun, 2023, 14:34

to create JSON .stringify

Binyamin
12 Jun, 2023, 14:34

Yes,

Sandeep K. Dasari
12 Jun, 2023, 14:34

Will hackathon judges judge me wrongly upon this?

Binyamin
12 Jun, 2023, 14:35

Mmm, on that I can't tell 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