Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this supposed to support for array? #13

Open
joannechan opened this issue Mar 28, 2017 · 5 comments
Open

Is this supposed to support for array? #13

joannechan opened this issue Mar 28, 2017 · 5 comments

Comments

@joannechan
Copy link

How should I represent the array field in the json file?

@cognitom
Copy link
Owner

Hi @joannechan, momy supports only these types described in README.

We may have two options, I think.

  1. make momy more customizable: custom converter or something
  2. 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.

@cognitom
Copy link
Owner

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

@joannechan
Copy link
Author

@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.

@Xsmael
Copy link

Xsmael commented Jun 7, 2017

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

@game5413
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants