Cordova-sqlite-storage: How to return column names with camel case?

Created on 31 Jan 2017  路  3Comments  路  Source: storesafe/cordova-sqlite-storage

Hi there, thanks for this awesome plugin. I'm facing a problem that my sqlite DB has Pascal Case applied both for the name of tables and columns. So when I read data it returns Pascal Case for column names. At this moment, my temporary solution is to use the lodash to convert the column names (keys) into Camel Case:
_.mapKeys(item, function (v, k) {return _.camelCase(k);})
But it seems this is not an elegant way to solve this issue. Is there any way to config this plugin to return data with Camel Case for column names from SQLite? Thanks in advance.

enhancement invalid question wontfix

Most helpful comment

I just figured out a better solution by using "As" in SQL query: "Select Name As name ... From ...". Anyway, thanks Brodybits for your quick reply. Cheers.

All 3 comments

It is not possible to configure this plugin to do such conversion for you and I would not recommend adding such an enhancement to this plugin. Such an enhancement would only add to the existing complexity of this plugin. I think your "workaround" solution is the best way to solve your problem. If it is too ugly you may want to put it into a special function or better yet refactor your code to cleanly encapsulate the database access part.

I just figured out a better solution by using "As" in SQL query: "Select Name As name ... From ...". Anyway, thanks Brodybits for your quick reply. Cheers.

That sounds like a better solution thanks!

Was this page helpful?
0 / 5 - 0 ratings