0

I am developing a Rest API using NodeJS and MySQL as the atabase. I use the standard package of npm for MySQL. I am using the following statement at the moment of insert data into DB:

INSERT INTO DATABASE.TABLE SET ?

And the JSON that I am trying to insert is:

{
     name    : "Lorem",
     surname : "Ipsum",
     email   : "lorem.ipsum@mail.com"
}

But in the database the order of columns is:

name/email/surname

Do you know if the order of the fields matters, or does the NodeJS mysql package respect the name of the columns?

AKX
  • 93,995
  • 11
  • 81
  • 98
Luisfermp
  • 3
  • 2

1 Answers1

0

It doesn't matter.

According to the JSON spec the order of the attributes is not significant.

And as you don't have brackets arround keys (which is required for valid JSON) I suppose you're missing it with regular JavaScript object which doesn't have ordering guaranties as well.

Glen Swift
  • 10,962
  • 14
  • 43
  • 73