Coder Social home page Coder Social logo

Comments (3)

teddis avatar teddis commented on July 20, 2024 1

Hi, I'm trying to find out why Typegoose is not creating a unique index on a new model property for me. It's not even creating an index. I'm assuming it works for you! Everything in my code looks correct and the property is defined as:

@prop({ index: true, unique: true })
sessionId?: string; 

I'm using Mongoose 5.2.5, MongoDB 3.6.6, and Node 9.2.1. My model references an existing collection. I dropped the collection and it rebuilt with only _id index. I guess I'll have to debug, but hoping someone can tip me off to any other config I'm forgetting or wasn't documented? Oh I also restarted mongodb without effect, and dropping the collection several times. I've had to create the index manually in mongodb (or Robo3T), and then unique index constraint works. Thanks.

from typegoose.

szokodiakos avatar szokodiakos commented on July 20, 2024

Hello!

Yes unfortunately I haven't covered all options yet, and yes all PR is appreciated! :)

from typegoose.

teddis avatar teddis commented on July 20, 2024

Nevermind. I discovered I had to call model.createIndexes() after compiling the model to ensure the index is built. I think it would be helpful for others to add this to your README.

from typegoose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.