feathers-rename-id

0.5.2 • Public • Published

feathers-rename-id

Build Status Greenkeeper badge

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 } });

Package Sidebar

Install

npm i feathers-rename-id

Weekly Downloads

2

Version

0.5.2

License

ISC

Last publish

Collaborators

  • kozzztya