mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 20:52:08 +08:00
Use lodash
This commit is contained in:
@ -14,13 +14,12 @@
|
||||
"errorhandler": "^1.2.0",
|
||||
"express": "^4.9.5",
|
||||
"got": "^1.2.2",
|
||||
"lodash": "^3.9.1",
|
||||
"lodash": "^3.9.2",
|
||||
"lowdb": "^0.7.1",
|
||||
"method-override": "^2.1.2",
|
||||
"morgan": "^1.3.1",
|
||||
"node-uuid": "^1.4.2",
|
||||
"pluralize": "^1.1.2",
|
||||
"underscore": "^1.8.3",
|
||||
"underscore-db": "^0.8.0",
|
||||
"update-notifier": "^0.2.2",
|
||||
"yargs": "^1.3.1"
|
||||
|
@ -1,7 +1,7 @@
|
||||
var express = require('express')
|
||||
var methodOverride = require('method-override')
|
||||
var bodyParser = require('body-parser')
|
||||
var _ = require('underscore')
|
||||
var _ = require('lodash')
|
||||
var low = require('lowdb')
|
||||
var pluralize = require('pluralize')
|
||||
var utils = require('./utils')
|
||||
@ -202,7 +202,7 @@ module.exports = function (source) {
|
||||
// Remove dependents documents
|
||||
var removable = utils.getRemovable(db.object)
|
||||
|
||||
_(removable).each(function (item) {
|
||||
_.each(removable, function (item) {
|
||||
db(item.name).remove(item.id)
|
||||
})
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
var _ = require('underscore')
|
||||
var _ = require('lodash')
|
||||
var uuid = require('node-uuid')
|
||||
var pluralize = require('pluralize')
|
||||
|
||||
@ -44,9 +44,9 @@ function createId (coll) {
|
||||
// Example: a comment that references a post that doesn't exist
|
||||
function getRemovable (db) {
|
||||
var removable = []
|
||||
_(db).each(function (coll, collName) {
|
||||
_(coll).each(function (doc) {
|
||||
_(doc).each(function (value, key) {
|
||||
_.each(db, function (coll, collName) {
|
||||
_.each(coll, function (doc) {
|
||||
_.each(doc, function (value, key) {
|
||||
if (/Id$/.test(key)) {
|
||||
var refName = pluralize.plural(key.slice(0, -2))
|
||||
// Test if table exists
|
||||
|
Reference in New Issue
Block a user