Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// We are evaling our own code here, not user input.
// Filter.field is our code, stringified and stored in an enum.
// The user choses one of the enum values and we convert the string
// back to a function which accepts a matcher and generates the
// query we need to find that field.
// eslint-disable-next-line security/detect-eval-with-expression
let queryGenerator = eval(filter.field) // eslint-disable-line no-eval
let attrQuery = queryGenerator({
[filter.comparator]: value,
})
query['$and'].push(attrQuery)
})
}
let result = await MongoPaging.find(client, {
query,
next,
previous,
limit,
})
return result
},
},
import mongoose from 'mongoose';
import URLSlugs from 'mongoose-url-slugs';
import mongoPagination from 'mongo-cursor-pagination';
const Song = mongoose.Schema({
title: String
}, {
timestamps: true
});
Song.plugin(URLSlugs('title', { field: 'slug', update: true }));
Song.plugin(mongoPagination.mongoosePlugin);
export default mongoose.model('Song', Song);