Use lodash

This commit is contained in:
Typicode
2015-05-25 14:54:15 +02:00
parent e8fe1ad89a
commit 8ef3065c12
3 changed files with 7 additions and 8 deletions

View File

@ -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"

View File

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

View File

@ -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