Skip to content

Commit

Permalink
style fix some more lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Sep 23, 2018
1 parent eedfc03 commit b54ce42
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
3 changes: 2 additions & 1 deletion examples/schema/schema.js
Expand Up @@ -4,7 +4,8 @@

'use strict';

let mongoose = require('../../lib'), Schema = mongoose.Schema;
const mongoose = require('../../lib');
const Schema = mongoose.Schema;

/**
* Schema definition
Expand Down
19 changes: 7 additions & 12 deletions lib/aggregate.js
Expand Up @@ -968,18 +968,13 @@ Aggregate.prototype.then = function(resolve, reject) {
*/

function isOperator(obj) {
let k;

if (typeof obj !== 'object') {
return false;
}

k = Object.keys(obj);
const k = Object.keys(obj);

return k.length === 1 && k
.some(function(key) {
return key[0] === '$';
});
return k.length === 1 && k.some(key => { return key[0] === '$'; });
}

/*!
Expand All @@ -993,13 +988,13 @@ function isOperator(obj) {
Aggregate._prepareDiscriminatorPipeline = prepareDiscriminatorPipeline;

function prepareDiscriminatorPipeline(aggregate) {
let schema = aggregate._model.schema,
discriminatorMapping = schema && schema.discriminatorMapping;
const schema = aggregate._model.schema;
const discriminatorMapping = schema && schema.discriminatorMapping;

if (discriminatorMapping && !discriminatorMapping.isRoot) {
let originalPipeline = aggregate._pipeline,
discriminatorKey = discriminatorMapping.key,
discriminatorValue = discriminatorMapping.value;
const originalPipeline = aggregate._pipeline;
const discriminatorKey = discriminatorMapping.key;
const discriminatorValue = discriminatorMapping.value;

// If the first pipeline stage is a match and it doesn't specify a `__t`
// key, add the discriminator key to it. This allows for potential
Expand Down
18 changes: 9 additions & 9 deletions lib/cast.js
Expand Up @@ -44,7 +44,7 @@ module.exports = function cast(schema, obj, options, context) {
val = obj[path];

if (path === '$or' || path === '$nor' || path === '$and') {
var k = val.length;
let k = val.length;

while (k--) {
val[k] = cast(schema, val[k], options, context);
Expand Down Expand Up @@ -100,11 +100,11 @@ module.exports = function cast(schema, obj, options, context) {

if (!schematype) {
// Handle potential embedded array queries
var split = path.split('.'),
j = split.length,
pathFirstHalf,
pathLastHalf,
remainingConds;
const split = path.split('.');
let j = split.length;
let pathFirstHalf;
let pathLastHalf;
let remainingConds;

// Find the part of the var path that is a path of the Schema
while (j--) {
Expand Down Expand Up @@ -250,10 +250,10 @@ module.exports = function cast(schema, obj, options, context) {
context: context
});
} else {
var ks = Object.keys(val),
$cond;
const ks = Object.keys(val);
let $cond;

k = ks.length;
let k = ks.length;

while (k--) {
$cond = ks[k];
Expand Down

0 comments on commit b54ce42

Please sign in to comment.