Skip to content

Auto generated id in cloudant is not a number - todo example not working with cloudant #2040

@cloudwheels

Description

@cloudwheels

Description / Steps to reproduce / Feature proposal

  • Deploy todo example connected to cloudant database using connector
  • Add some todos
  • get todos as a list
  • get todos by id

Current Behavior

inserted autogenerated ids are returned as a the numeric part of the document id if it starts with one, so that:
database records with ids:

id"3e8428d6ba9feb6819cfb30756d3d310"
{
 "_id": "3e8428d6ba9feb6819cfb30756d3d310",
 "_rev": "3-9c0030f442f6ac47aab94ceb359179c8"
}
id"70f03fa5007cbbc02690a1c65b3f3e78"
{
 "_id": "70f03fa5007cbbc02690a1c65b3f3e78",
 "_rev": "1-8ec76b46879aa8c3147debb9ab4dedf3"
}
id"75b55970bb16205e4c377da12d97bcf7"
{
 "_id": "75b55970bb16205e4c377da12d97bcf7",
 "_rev": "1-e3f8eca5e6afbac64b52ccc1aee1ec1d"
}
id"b54ad55e77d3c0c5cda2805731cfede0"
{
 "_id": "b54ad55e77d3c0c5cda2805731cfede0",
 "_rev": "1-f03a33fff19afa3f3464ff9a6b05d43d"
}
id"e096ae6ef623c7925d2d76716013bbdc"
{
 "_id": "e096ae6ef623c7925d2d76716013bbdc",
 "_rev": "1-62a17081d83c506b0763fc9d28c5df95"
}

are returned as below by the api's GET todos:

[
    {
        "id": 3,
        "title": "get better at this"
    },
    {
        "id": 70,
        "title": "try again"
    },
    {
        "id": 75,
        "title": "add"
    },
    {
        "id": null,
        "title": "get milk"
    },
    {
        "id": null,
        "title": "test post",
        "desc": "testing post",
        "isComplete": false
    }
]

GET todos/{id} doesn't work (404 not found)

Expected Behavior

GET todos/{id} returns a todo with id={id}

Id need to be handled by loopback as a string to return the cloudant doc id.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions