New Field Type: Object & Array

Any info on the new object and array field types located in the Corvid database? I haven’t been able to find any documentation on them.

@brett-haralson Any insight?

Good question. This is a really advanced feature - and I believe one of the Corvid masters is planning on writing something about it.

@Eric

Those new types have been added at the request of the Corvid Masters. The documentation will come later.

Those fields are for advanced coders. They are used to store javascript object in the DB without transformation into a string. This means you can use object type to store javascript variable directly in your DB.

Objects are extremely useful when dealing with complex data structures (like geo data ) or with non-uniform data.

Arrays are just a table of Value. You used them to store a list of string(like tag field) number, or even object.

Does that answer your question?

@Eric. I use it to store $w-element properties (Required, MaxLen, etc) as key-value pairs. I will also use it in a former project where I stored query-results in a string , so stringified. It´s better to keep it as an object, so Date data types can stay dates instead of strings.

Um… releasing a feature without documentation, regardless of whether it is for advanced coders or not is a really bad idea. I just started to see errors in the Content Manager out of the blue about values not matching the field type for a database where I am storing arrays as strings. It begs the question: if I don’t change the field type from text to array or object, will code start to break?

@Dave now that you can store your arrays directly in collection I don’t see any reason not to use the feature.

There isn’t much documentation because none is really necessary.

There are much more complexes types such as Media gallery and address that do need a bit of documentation in order to be used properly but Arrays and Object are standard feature of javascript :slight_smile:

Hi Quentin, Will I be able to use HTML element in this object field?

I’m not sure to understand what you want to do. Could you give more details?

If you which to store HTML text field are good enough but I’m not sure to understand why

‘…documentation because none is really necessary’ … Maybe that’s true but it still means that the existing documentation is incomplete because it gives lists of the types of fields the DB’s support and these new ones are not listed (Note 1) When there are lists like this that are missing supported features - surely that needs to be addressed. And what is the difference between using an array and the tags? Both of them are arrays in javascript but the tags type is an array of strings in javascript. It’s reasonable to assume that the new array type will take any type of elements even objects right? Surely it would be better to add these to the list in the existing documentation than have people have to assume and test for themselves?

Note 1: Eg https://support.wix.com/en/article/field-type-support-and-limitations-in-the-content-manager
Eg https://support.wix.com/en/article/about-your-content-collection-fields
Eg. https://www.wix.com/corvid/reference/wix-data.html

Did anyone find any documentation? What’s the correct format for storing an array in the collection?

1 Like

I would like to be able to place some html in the object field. I would like to be able to add latex code, rendered via mathjax. If I select the text as the field type, the latex doesn’t work. Is using “object” the correct way to do this? So can the object be html code?

Can anyone provide a solid use case with code for a collection object?

Even just the use case would be great. Just keep it simple for code noobs like me.

I’ve done some good work with arrays in collections and love them. Getting data in and out of a collection array is a bit of a trick, but it works; it’s incredibly flexible; it’s fast, and arrays leverage the power of collections, IMO.

Just watch your use of null. To pass or compare null, you need (null) with parentheses. Used without the parentheses gives quirky, unreliable results. But objects sound very interesting.

Anyone got anything good?

Did you find out what the correct format is for storing an array?