simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 222 forks source link

Store comma seperated values for a single column. #138

Open aniruddhasm opened 6 years ago

aniruddhasm commented 6 years ago

Hello,

I want to store values in the form of comma separated ids. For eg : 1,2,3... Consider the below example Songs table with field id, name. Playlists table with id, playlist_name, songs_ids. 1 playlist has many songs. So I was storing them comma separated values. In settings I've added the below code for songs_ids column

{
                "name": "songs_ids",
                "verbose": "Songs",
                "control": {
                    "select": true,
                    "multiple": true
                },
                "oneToMany": {
                    "table": "songs",
                    "pk": "id",
                    "columns": [
                        "name"
                    ]
                },
                "type": "varchar(255)",
                "allowNull": false,
                "defaultValue": null,
                "listview": {
                    "show": true
                },
                "editview": {
                    "show": true
                }
            },

In the dropdown I am able to select multiple songs but while inserting in database I'm getting the below error

Error: ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1. 

Please let me know whether I've implemented it properly.