mirror of
https://github.com/strapi/strapi.git
synced 2025-12-30 00:37:24 +00:00
Remove Mongoose warning logs
This commit is contained in:
parent
4157f99af8
commit
2115124931
@ -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 }));
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ module.exports = {
|
||||
|
||||
virtualFields.push(
|
||||
this
|
||||
.update({
|
||||
.updateOne({
|
||||
[this.primaryKey]: getValuePrimaryKey(params, this.primaryKey)
|
||||
}, values, {
|
||||
strict: false
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
});
|
||||
},
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user