Remove Mongoose warning logs

This commit is contained in:
Aurélien Georget 2019-01-23 16:56:04 +01:00
parent 4157f99af8
commit 2115124931
8 changed files with 20 additions and 17 deletions

View File

@ -64,7 +64,7 @@ module.exports = {
const filters = strapi.utils.models.convertParams('<%= globalID.toLowerCase() %>', params);
return <%= globalID %>
.count()
.countDocuments()
.where(filters.where);
},
@ -98,7 +98,7 @@ module.exports = {
const data = _.omit(values, <%= globalID %>.associations.map(a => a.alias));
// Update entry with no-relational data.
const entry = await <%= globalID %>.update(params, data, { multi: true });
const entry = await <%= globalID %>.updateOne(params, data, { multi: true });
// Update relational data and return the entry.
return <%= globalID %>.updateRelations(Object.assign(params, { values: relations }));

View File

@ -60,7 +60,9 @@ module.exports = function (strapi) {
// Connect to mongo database
const connectOptions = {};
const options = {};
const options = {
useFindAndModify: false
};
if (!_.isEmpty(username)) {
connectOptions.user = username;
@ -77,6 +79,7 @@ module.exports = function (strapi) {
connectOptions.ssl = ssl === true || ssl === 'true';
connectOptions.useNewUrlParser = true;
connectOptions.dbName = database;
connectOptions.useCreateIndex = true;
options.debug = debug === true || debug === 'true';

View File

@ -239,7 +239,7 @@ module.exports = {
virtualFields.push(
this
.update({
.updateOne({
[this.primaryKey]: getValuePrimaryKey(params, this.primaryKey)
}, values, {
strict: false

View File

@ -15,7 +15,7 @@ module.exports = {
count: async function (params) {
return Number(await this
.where(params.where)
.count());
.countDocuments());
},
search: async function (params, populate) { // eslint-disable-line no-unused-vars
@ -81,7 +81,7 @@ module.exports = {
return this
.find({ $or })
.count();
.countDocuments();
},
findOne: async function (params, populate, raw = true) {
@ -150,7 +150,7 @@ module.exports = {
deleteMany: async function (params) {
return this
.remove({
.deleteMany({
[this.primaryKey]: {
$in: params[this.primaryKey] || params.id
}

View File

@ -13,7 +13,7 @@ module.exports = {
count: async function (params = {}) {
return Number(await this
.count(params));
.countDocuments(params));
},
findOne: async function (params, populate) {
@ -68,7 +68,7 @@ module.exports = {
};
}
return this.update(search, params, {
return this.updateOne(search, params, {
strict: false
})
.catch((error) => {
@ -82,7 +82,7 @@ module.exports = {
delete: async function (params) {
// Delete entry.
return this
.remove({
.deleteOne({
[this.primaryKey]: params[this.primaryKey] || params.id
});
},

View File

@ -13,7 +13,7 @@ module.exports = {
count: async function (params = {}) {
return Number(await this
.count(params));
.countDocuments(params));
},
findOne: async function (params, populate) {
@ -68,7 +68,7 @@ module.exports = {
};
}
return this.update(search, params, {
return this.updateOne(search, params, {
strict: false
})
.catch((error) => {

View File

@ -13,7 +13,7 @@ module.exports = {
count: async function (params = {}) {
return Number(await this
.count(params));
.countDocuments(params));
},
findOne: async function (params, populate) {
@ -65,7 +65,7 @@ module.exports = {
};
}
return this.update(search, params, {
return this.updateOne(search, params, {
strict: false
})
.catch((error) => {
@ -79,7 +79,7 @@ module.exports = {
delete: async function (params) {
// Delete entry.
return this
.remove({
.deleteOne({
[this.primaryKey]: params[this.primaryKey] || params.id
});
},
@ -87,7 +87,7 @@ module.exports = {
deleteMany: async function (params) {
// Delete entry.
return this
.remove({
.deleteMany({
[this.primaryKey]: {
$in: params[this.primaryKey] || params.id
}

View File

@ -110,7 +110,7 @@ module.exports = function () {
});
strapi.models['core_store'].orm === 'mongoose'
? await strapi.models['core_store'].update({ _id: data._id }, data, { strict: false })
? await strapi.models['core_store'].updateOne({ _id: data._id }, data, { strict: false })
: await strapi.models['core_store'].forge({ id: data.id }).save(data, { patch: true });
} else {
Object.assign(where, {