From f39ad84f544f1bb038e91dd9886c0308c299a87f Mon Sep 17 00:00:00 2001 From: Rhio Kim Date: Tue, 29 Mar 2016 19:21:48 +0900 Subject: [PATCH] Support id generation compatible with MongoDB, #245, #39, #24 --- package.json | 2 +- src/server/router/plural.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c9f200ca9..123eaf324 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "lowdb": "^0.10.0", "method-override": "^2.1.2", "morgan": "^1.3.1", - "node-uuid": "^1.4.2", + "node-uuid": "^1.4.7", "object-assign": "^4.0.1", "pluralize": "^1.1.2", "server-destroy": "^1.0.1", diff --git a/src/server/router/plural.js b/src/server/router/plural.js index 2c409f2c3..1c953a5ec 100644 --- a/src/server/router/plural.js +++ b/src/server/router/plural.js @@ -2,6 +2,7 @@ var express = require('express') var _ = require('lodash') var pluralize = require('pluralize') var utils = require('../utils') +var uuid = require('node-uuid') module.exports = function (db, name) { @@ -209,6 +210,8 @@ module.exports = function (db, name) { req.body[key] = utils.toNative(req.body[key]) } + req.body.id = uuid.v4(); + var resource = db(name) .insert(req.body)