by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Elirehema Paul
    @elirehema
    @SyntleLmao you can just disconnect with mongoose.connection.close()
    or you can add disconnect callback in your mongoose.connect
    Rob
    @borriej
    @elirehema thank you
    Elirehema Paul
    @elirehema
    Okay
    Adedeji Stephen
    @ionware
    Hello everyone.
    I'm Stephen, from Nigeria. I recently started using MongoDB and Mongoose, and I am glad to be here. I hope to learn from everyone, and grow my knowledge.
    EaGLE-25
    @EaGLE-25
    Hello guys im running into cannot set property of undefined error . This is the stack overflow link please help me out guys - https://stackoverflow.com/questions/61088207/mongoose-cannot-set-property-of-to-undefined-whenever-i-try-to-create-a-new/61088380#61088380
    Adedeji Stephen
    @ionware
    benchudev
    @benchudev
    Hi guys, having a very strange issue with save and subdocument. getting Cannot create field '-1' in element {subdocument}. when saving the parent document with no modifications. The subdocument Schema has hooks to encrypt/decrypt two fields on save/update and init. mongo debug shows the issue is on the parent document updateOne function, it is trying to set an object with undefined to -1 position in the array. Baffled. Works fine if removing the hooks. Have another subDocument with same encrypt/decrypt function in hooks and that works fine.
    hillct
    @hillct
    Good evening all. Is there a convenient way to update existing documents in the scenario where new elements with defaults have been added to a model subsequent to document creation, thereby causing creation of the element (with the default values) using some generic methofs like Schema.ApplyDefaults() to cause a mass update, where those elements don’t already exist/have values?
    Caleb David
    @microworlds

    Hello guys, I posted a question on stackoverflow, any answers to that will be appretiated. Thank you

    https://stackoverflow.com/questions/61273658/modify-and-return-an-object-inside-an-async-function

    Rob
    @borriej
    hi guys :wave:
    question, im using a single page app with nodejs mongoose
    this uses preflight / options ofcourse
    now, im trying to delete myself as a user via my post delete api i created
    the schema pre middleware i set up clean all the relations
    userSchema.pre('remove', function (next) {
    BUT when the PREFLIGHT fires, it is 200 success... but i get a 500 error
    with response unauthorized
    as if the preflight already executed the delete
    and the jwt token is not valid anymore
    should i use userSchema.post or how to deal with OPTIONS and my delete api?
    Rob
    @borriej
    ah solved it
    srry
    sendgrid.env needed to be sourced first :P
    Elirehema Paul
    @elirehema
    Hi
    Divine C
    @Divine1
    hi
    Automattic/mongoose#8900 - please let me know if you have solution for this issue?
    Kev
    @lineus
    @Divine1 in your uri string you have mongodb://host:port/db, host:port/db i think you should only have the database on the end of the last host:port combo in the list.
    should be : mongodb://host:port,host:port/db
    hillct
    @hillct
    Good afternoon. I wonder if anyone might be able to clarify for me, how to set a default value of [] (empty array) for a schema element. My attempt can be found here https://pastebin.com/PWzW4S20
    Burak Targaç
    @btargac
    Hi guys, this might be a simple question for you
    I couldn't convert timestaps of a schema to milliseconds
    in the original documentation it states that to set timestamps
    timestamps: { currentTime: () => Math.floor(Date.now() / 1000) }
    but it still returns and sets as javascript date format any help would be appreciated, thanks in advance
    this is what it retuns in a find() query
    "createdAt": "1970-01-19T09:12:30.021Z", "updatedAt": "1970-01-19T09:12:30.021Z",
    Kev
    @lineus
    @Divine1 are you around?
    Burak Targaç
    @btargac
    by the way I changed my strategy and found another solution, you can ignore my question.
    Divine C
    @Divine1
    @lineus yes lineus. i haven't yet tried the solution proposed in thread. i will try it in few hours and update the status to you.
    @lineus i have posted a question in stackoverflow , if you have sometime please take a look at it . i appreciate your support lineus. https://stackoverflow.com/q/61567871/3673073
    Divine C
    @Divine1
    @lineus after applying your recommendation it works fine. Thank you. Which readPreference would you prefer? i tried secondary secondaryPreferred nearest. with secondaryPreferred, the request always gets sent to the PrimaryNode. with secondary, the request gets sent to the secondaryNode. with nearest , the request alternates between secondaryNode and primaryNode but i can observe that nearest takes toll on response time .
    Kev
    @lineus
    @Divine1 do your replicaSet members all run on the same host or are they running on different machines?
    Divine C
    @Divine1
    @lineus rightnow its samehost-differentPort. i have planned to run it on different hosts. but if i run a single instance of mongodb on a particular host, will mongodb utilize the resources of the entireHost? it seems to work this way, ....
    Kev
    @lineus
    that's not something I've tested but I suppose it depends on where your primary is actually constrained. If your bottleneck is the network or ram I don't suppose having them on the same host will do much for you. If the primary's mongod process is bound on the cpu and you have extra cores, running the extra processes might help, but you'll have to run benchmarks to really know for sure. I'm glad you got it sorted out @Divine1
    5 replies
    Caleb David
    @microworlds
    Hello guys, I have been getting a mongoose error "Can't save() doc multiple times". I posted the question on stackoverflow. Any assistance would be appreciated, thank you. Here's the link: https://stackoverflow.com/questions/61607900/updating-a-user-concurrently-in-mongoose-using-model-save-throws-error
    Kev
    @lineus
    @microworlds I added an answer to your stackoverflow question.
    if you need some help I should be around later
    Christian Roy
    @roychri
    Is there any way to tell which queries actually end up on the primary or the secondaries? (and which one the secondary it used) ?
    Carlos Rocha
    @CarlosRocha2409_gitlab
    Do you guys have a method for removing all subdocuments of a document using MAP, because i have an array of 5 subdocuments, i used Document.subdocument.map(sudocument=>{subdocument.remove()}); and deletes 3 of the 5 subdocuments
    Oron Sharabi
    @oronsh
    Hello, i'm trying to use mongoose with typescript and using connection.createCollection and can't figure out the return type Promise<Something?> anyone knows please?
    Ravindra Sisodia
    @InfoSecRavindra
    Is this possible to make an array property select false?
    Elirehema Paul
    @elirehema
    C'mon