loopbackio / loopbackio/loopback-connector-cassandra

Unable to save array entry for list<text> column

Open
#84 12 comments 0 reactions 1 assignee View on GitHub

@raymondfeng is already working on this.

Since Oct 22, 2019.

bug
Dominant language
JavaScript
Stars
13
Forks
22
PR merge metrics
No merged PRs in 30d

Description

I am using Cassandra datasource in loopback 3, and trying to store values in list datatype column of a table(keyspace) of Cassandra datasource. But while creating an entry from loopback explorer, we are getting **TypeError: Not a valid list value, expected Array obtained** '["Morning","Afternoon","Evening"]'

Here is my loopback model:
```
{
"name": "Time",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"options": {
"type": "array",
"format": "list"
}
},
"validations": [],
"acls": [],
"methods": {}
}
```
Tried debugging loopback-cassandra-datasource and saw **options** converted to string in params.

Data passed from loopback explorer:
```
{
"options": ["Morning","Afternoon","Evening"]
}
```

Data logged from beforeRemote hook of the model:
```
{ options:
[ 'Morning',
'Afternoon',
'Evening' ]
}
```
package.json
```
"dependencies": {
"loopback": "3.26.0",
"loopback-boot": "2.28.0",
"loopback-component-explorer": "6.4.0"
"loopback-connector-cassandra": "1.7.1"
}
```
The **typeof options** is object. I was debugging loopback cassandra connector and found **typeof options** as string in **encoder.js** of cassandra-driver node module. We have migrated from MongoDB to Cassandra and didn't face any issues for MongoDB driver. To what type or which format do I need to set for options property? Please let me know if any additional information required. Thank you in advance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.