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

Improperly Inserting Array Properties Into MongoDB #1508

Closed
kevdougful opened this issue Jul 10, 2018 · 4 comments
Closed

Improperly Inserting Array Properties Into MongoDB #1508

kevdougful opened this issue Jul 10, 2018 · 4 comments
Assignees
Labels
bug db:MongoDB Topics specific to MongoDB

Comments

@kevdougful
Copy link

kevdougful commented Jul 10, 2018

Description / Steps to reproduce / Feature proposal

I have a Publication model that basically describes an entry in a bibliography. I'd like to store the author names for each publication as an array of strings:

export class Publication extends Entity {
  // ...
  @property.array(String) authors: string[]
  // ...
}

and a controller like this:

export class PublicationController {

  constructor(@repository(PublicationRepository) protected repo: PublicationRepository) {}

  @post('/publications')
  async createPublication(@requestBody() publication: Publication) {
    return await this.repo.create(publication)
  }
}

Current Behavior

I'm using MongoDB as a data source and the data is not being stored as an array but rather as a single comma-separated string. I've found that if I comment out the authors property in the model, POST a new publication, then turn the authors property back on any subsequent GET /publications will return objects where the authors property is an array.

Expected Behavior

I expect the @property.array(String) to properly insert data as an array in both the database and in responses from the REST API.

See Reporting Issues for more tips on writing good issues

@jannyHou jannyHou self-assigned this Jul 17, 2018
@jannyHou
Copy link
Contributor

jannyHou commented Jul 17, 2018

Trying it, will update my finding later.


Update

I reproduced the error. Seems decorator property.array generates a wrong definition, or it's not compatible with the mongodb connector.

I may need more time to use a LB3 app to figure out the correct property definition, then we know how to fix ^

@dhmlau dhmlau added the bug label Jul 23, 2018
@dhmlau
Copy link
Member

dhmlau commented Jul 23, 2018

@jannyHou , do we know enough to estimate or should i just put it in the backlog?

@jannyHou
Copy link
Contributor

@dhmlau Verified it's a bug. It needs time to investigate including some debug setup, I agree to put it in the backlog, changed the pipeline.

@shimks shimks self-assigned this Jul 26, 2018
@shimks shimks mentioned this issue Jul 27, 2018
7 tasks
@bajtos bajtos added this to the August Milestone milestone Jul 31, 2018
@shimks
Copy link
Contributor

shimks commented Aug 10, 2018

Fixed with #1570. Closing as done

@shimks shimks closed this as completed Aug 10, 2018
@bajtos bajtos added the db:MongoDB Topics specific to MongoDB label Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug db:MongoDB Topics specific to MongoDB
Projects
None yet
Development

No branches or pull requests

5 participants