lowdb-api icon indicating copy to clipboard operation
lowdb-api copied to clipboard

Feature: Store resource data under a `data` key

Open alblandino opened this issue 8 years ago • 2 comments

I am adding a new index called data to protect the self-generated id in case the user adds a field ID

For example, I am sending these values:

{
    id: 12,
    fname: "Joel",
    lname: "Jaime"
}

I receive and storage the values in this way:

{
    id: 1,
    data: {
        id: 12,
        fname: "Joel",
        lname: "Jaime"
    }
}

The behavior of the module is the same, the only thing that in this case allows the user to save his own ID of his application since by default lowdb does not allow a dynamic ID

alblandino avatar Oct 31 '17 15:10 alblandino

Hey @jblandino! Nice to see you there mate! Would not be better to allow user specify the id if they want to? I think it is more simple and straightforward to allow the user to provide and id or let the api to auto generate one.

What do you think?

rmariuzzo avatar Oct 31 '17 15:10 rmariuzzo

Will continue the discussion here: #2

rmariuzzo avatar Oct 31 '17 15:10 rmariuzzo