-
Notifications
You must be signed in to change notification settings - Fork 19
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
id mapping does not work? #11
Comments
That was definitely useless documentation on our part. We added it because all the other adapters allow it as well but it looks like NeDB does not support changing the id property name. I removed it from the documentation and you are correct with your suggestion to use a hook to do the mapping from |
excellent. thanks for the clarification. |
Is is still true as of today? Because the |
I saw the unit tests, but I failed to make it working on a freshly generated project from the CLI:
I'm not sure what I could have done wrong since it's pretty straightforward. I ended up remapping in pre/post hooks, but that's frustrating :/ |
Just to complete with some code: // Initializes the `scores` service on path `/scores`
const createService = require('feathers-nedb');
const createModel = require('../../models/scores.model');
const hooks = require('./scores.hooks');
module.exports = function (app) {
const Model = createModel(app);
const options = {
Model,
id: 'playerId'
};
// Initialize our service with any options it requires
app.use('/scores', createService(options));
// Get our initialized service so that we can register hooks
const service = app.service('scores');
service.hooks(hooks);
}; |
Just like MongoDB, NeDB needs the |
Thanks for the clarification 👍 That might be a useful note on the docs regarding this section! |
Almost all good, except that trying to create a new entry using a
The request that was working fine before (by mapping
Any ideas? |
Please create a new issue with an example. |
Hi,
my frontend requires a "id" to come from the rest service. I tried all sorts of different options to map _id to id, but no avail. i tried it with 1.3 and 2.0.1. I can do it with before and after hooks, but because you put it in the docs i'm assuming it should be handled by feathers-nedb. Is this assumption correct?
here is my code with feathers-nedb 1.3:
and the result of a get request http://localhost:3333/todos/EMVqs9KyTImCIKyE
Thanks for your time.
The text was updated successfully, but these errors were encountered: