Odd Issue with Collection Object Array

I’ve created a simple collection object array. The array has 16 items, 2 values per item.

All looks and works good, but I have a yellow warning in the collection manager for the field that says the value does not match the field type.

Every example of an object array I’ve found shows strings for values. I had integers and strings, but even when I save my integers as strings, the warning persists.

Any ideas?

Coding is about ACTIONS and REACTIONS or INPUT and OUTPUT .

You will surelly agree, that creating a site without hosting a DATABASE in the background, makes not much sense.

And here we already go —> INPUT into DATABASE + OUTPUT from databse.
Furthermore you work with CODE and you are creating functions, which do something, giving you some RESULTS → and here we go again → INPUT/OUTPUT.

A good coder always uses —> INPUT → to be able to CHECK → OUTPUT.

So, now it gets interessting !!!

How to do so? The answer is easy —> USING —> CONSOLE ← (console.logs).

Did you already tried to inspect all your OUTPUTS ??? (results you get back) ???

STEP-1: (checked) !!!
Ok, you were able to write some data into an OBJECT-FIELD.

STEP-2: (checked) !!!
Now you normaly first should take a look what you got inside of your DB
You got…

But what exactly does the WARNING tell us ? ? ? Something like…

Maybe something like that…

STEP-3: Why does this happen → BRAINSTORMING!!!

STEP-4: Question —> Is my inserted DATA really an —> OBJECT ??? Or did i do a failure?

STEP-5: First making clear what an OBJECT is and how it is built…



let myOrdinaryEmptyObj = {};


myOrdinaryEmptyObj.firstName = "John";
myOrdinaryEmptyObj.lastName = "Doe";
myOrdinaryEmptyObj.age = 10;
myOrdinaryEmptyObj.eyeColor = "blue";

RESULT of an ordinary simple OBJECT:

    firstName: "John",
    lastName: "Doe",
    age: 10,
    eyeColor: "blue"

But trying to write this object into databse, will not work! WHY???

Indeed it will work, but not the way you want it.
It will write data into different columns of a row → normal DB-INSERT / DB-SAVE.

But you want something else. You want to write the WHOLE-OBJECT into a DB-FIELD.
And this DB-FIELD is of TYPE - - → OBJECT and is called for example —> “obj”.

So we have an OBJECT-Field inside your databse called - - → “obj” which expects an OBJECT as INPUT.

Let’s create that OBJECT…

let myObject = {
        "obj": {
            firstName: "John",
            lastName: "Doe",
            age: 10,
            eyeColor: "blue"

Now let’s generate some CODE, to SAVE/INSERT that OBJECT into our DATABSE.
Let’s say the ID of our DATABSE is - - → “myDatabase”…

import wixData from 'wix-data';
    let myObject = {
        "obj": {
            firstName: "John",
            lastName: "Doe",
            age: 10,
            eyeColor: "blue"

        wixData.insert('myDatabase', myObject)
        .then((results) => {console.log(results)})
        .catch((err)=> {console.log(err);});

We click the button and the SAVE-PROCESS starts and saves our OBJECT into our “obj” DATABSE-FIELD, let’s see the result…:grin:

WTF!!! How did that work ???

As you can see, you were just right now, able to write your OBJECT-DATA into your database.
But what exactly is now the difference and advantage of this “OBJECT-FIELD” inside your database?

If you would have been used the SEARCH of this VELO-FORUM, you maybe would find the following post…

Yes, you won’t find much information about this FIELD-TYPE inside the VELO-API-DOCs, but by some logical investigations and some tryings and testings, normaly you could get it.

Conclusion of all that is —> USE MORE THE CONSOLE and all it’s console-log-outputs.

Further questions:
-What was the difference to your version?
-Are you sure, that you need the OBJECT-FIELD and not the ARRAY-FIELD ?
-What was the advantage of that object-field one more time?
-Am i able to do the same inside of an ARRAY-FIELD ?
-What would i need to generate the same inside an ARRAY-FIELD ?
-and surely some more questions…

Now start your Editor+Brain+CONSOLE and let’s go :wink: