Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(node:25375) DeprecationWarning: Mongoose: the isAsync option for custom validators is deprecated. Make your async va lidators return a promise instead: https://mongoosejs.com/docs/validation.html#async-custom-validators #8184

Closed
denzilgupta opened this issue Sep 20, 2019 · 6 comments
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@denzilgupta
Copy link

This is my code:

tags: {
type: Array,
validate: {
isAsync: true,
validator: function(value, callback) {
setTimeout(() => {
const result = value && value.minlength > 0;
callback(result);
}, 4000);
},
message: 'A course must have at least one tag'
}
}

when I try to insert a value into mongodb, I get the below warning:
(node:25375) DeprecationWarning: Mongoose: the isAsync option for custom validators is deprecated. Make your async va lidators return a promise instead: https://mongoosejs.com/docs/validation.html#async-custom-validators

I saw the documentation and they too have used a callback function.
Please help me solve this problem!

Node Version:
v10.16.3

MongoDB Shell Version:
v4.2.0

Mongoose Version:
v5.7.1

@vkarpov15 vkarpov15 added this to the 5.7.3 milestone Sep 26, 2019
@vkarpov15 vkarpov15 added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Sep 26, 2019
@vkarpov15 vkarpov15 modified the milestones: 5.7.3, 5.7.4 Sep 27, 2019
@vkarpov15 vkarpov15 modified the milestones: 5.7.4, 5.7.3 Sep 29, 2019
@ghost
Copy link

ghost commented Nov 9, 2019

@denzilgupta please how did you resolve this issue. I have the same issue now

@denzilgupta
Copy link
Author

@LouiseEmike Can you show me the code? I think I'll be able to help you out better then.

@receptopalak
Copy link

@denzilgupta
I get the same error, can you help me urgently

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
//const GeoJSON = require('mongoose-geojson-schema');
const {
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
Geometry,
GeometryCollection
} = require('mongoose-geojson-schemas');

//new geo location schema
//const Geo = new Schema(Schema.Types.Point);

const geojson = new Schema(

{
    konum: {
        type:  String,
        default: "Sazlıdere"
    },
    type: {
        type: String,
        default: "Feature"
    },
    properties: {
        name: {
            type: String,
            default: "bina"
        },
        surname: {
            type: String,
            default: "bina"
        }
    },
    geometry: Polygon
}

);
const barrage = mongoose.model('intersect', geojson);
module.exports = barrage;

@denzilgupta
Copy link
Author

@denzilgupta
I get the same error, can you help me urgently

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
//const GeoJSON = require('mongoose-geojson-schema');
const {
Point,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon,
Geometry,
GeometryCollection
} = require('mongoose-geojson-schemas');

//new geo location schema
//const Geo = new Schema(Schema.Types.Point);

const geojson = new Schema(

{
    konum: {
        type:  String,
        default: "Sazlıdere"
    },
    type: {
        type: String,
        default: "Feature"
    },
    properties: {
        name: {
            type: String,
            default: "bina"
        },
        surname: {
            type: String,
            default: "bina"
        }
    },
    geometry: Polygon
}

);
const barrage = mongoose.model('intersect', geojson);
module.exports = barrage;

Are you getting an error on this file? Cause it seems to look fine.

@receptopalak
Copy link

@denzilgupta yes, ı getting an error, ı think because of mongoose-geojson-schema npm package, can you help me ?

@vkarpov15
Copy link
Collaborator

@receptopalak please open a new issue and follow the issue template. Also, check out our geojson docs: https://mongoosejs.com/docs/geojson.html

@Automattic Automattic locked as resolved and limited conversation to collaborators Nov 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

3 participants