mariano / node-db-mysql

MySQL database bindings for Node.js
http://nodejsdb.org
150 stars 30 forks source link

Trouble with columns object #57

Closed boozedog closed 12 years ago

boozedog commented 12 years ago

JSON.stringify(columns) gives this:

[{"name":"id","type":2},
{"name":"url","type":0},
{"name":"create_ts","type":6},
{"name":"update_ts","type":6}]

but when I run the following code:

for (col in columns) {
    console.log(col.name + ' ' + col.type);
}

I'm getting undefined for both name and type .

Any ideas? Apologies in advance if I'm missing something obvious ...

mengy007 commented 12 years ago

Try this columns[col].name and columns[col].type I believe col is the index and not the actual object. I could be wrong.

boozedog commented 12 years ago

You're right ... I need to read my Javascript manual more carefully, LOL

Thanks for your help!

mengy007 commented 12 years ago

Glad I could help. =]