feathers-rename-id
v0.5.2
Published
Package to use id instead of _id
Downloads
19
Readme
feathers-rename-id
Can change "_id" to "id" for all requests.
Configure
const mongooseService = require('feathers-mongoose').Service;
const Service = require('feathers-rename-id')(mongooseService);
const Post = require('./post-model');
module.exports = function() {
const app = this;
app.use('/posts', new Service({
Model: Post,
newIdName: 'id' // Default value - 'id'
}));
};
Usage
const post = await app.service('/posts').create({ id, text });
const got = await app.service('/posts').get(post.id);
const found = await app.service('/posts').find({ query: { id: post.id } });
const patched = await app.service('/posts').patch(null, { text }, { query: { id: post.id } });
const updated = await app.service('/posts').update(null, { text }, { query: { id: post.id } });
const removed = await app.service('/posts').remove(null, { query: { id: post.id } });