momy
momy copied to clipboard
Is this supposed to support for array?
How should I represent the array field in the json file?
Hi @joannechan, momy
supports only these types described in README.
We may have two options, I think.
- make
momy
more customizable: custom converter or something - add JSON data type support
The latter one would be easier to implement, but analyzing JSON
type may have some difficulty.
Note: MySQL has no array
data type, but in v5.7 they introduced the new type for JSON
.
To achieve the first option, we may need to allow JavaScript style configuration (momyfile.js
), instead of momyfile.json
.
// momyfile.js could be like this...?
const config = {
"src": "mongodb://localhost:27017/dbname",
"dist": "mysql://root:password@localhost:3306/dbname",
"prefix": "t_",
"case": "camel",
"collections": {
"collection1": {
"_id": "number",
"field1": "string",
// This doesn't work at this point,
// but this type of conversion could be useful in some cases.
"field2": {
"type": "string",
"convert": val => Array.isArray(val) ? val.join('\t') : val
}
}
}
}
export default config
@cognitom Have this support for json datatype would be hugely beneficials. Is this something that's going to be supported in the near future? I am comparing this with mosql which only support postgres.
i strongly agree with @joannechan supporting arrays would be so much useful especially when it comes to mongoDB, its hard to find a database without arrays. But is it possible to treat the array as a collection and documents inside would be the collection documents ? since they also have an _id field
Maybe my contribute progress #31 fit with your requirements, i had already implement feature that if some column have data type like array on json, it will be maping to new table and adding parent ID to that row, just add some relations object key on momyfile.json to make it read the mapping.
cc @joannechan , @Xsmael (sorry for directly mention, just want to be helpful)
PS: Sorry, if my english language so bad.