Coder Social home page Coder Social logo

Comments (6)

kevin-frugier avatar kevin-frugier commented on July 20, 2024 6

I would really fancy a solution in the direction @jorge-recio mentioned.
I'm new to Typescript (not JS) otherwise I would have done a PR that does just that.

In the meantime, for anyone in need of compound indexes, I've done a temporary workaround in a fork where indexes can be given as indexes in the GetModelForClassOptions param of the getModelForClass method : https://github.com/kevin-frugier/typegoose
I've added the postinstall-build package in my fork so it can be used "as such" from GitHub (since compilation to JS is required).

e.g:

const options: GetModelForClassOptions = ...;
options.indexes = [{ fields: { firstName: 1, lastName: 1 }, options: { unique: true } }];
const UserModel = new User().getModelForClass(User, options);

from typegoose.

jorge-recio avatar jorge-recio commented on July 20, 2024 4

Thanks for your quick response. I think it could be done whith a class level decorator like @indexes.

from typegoose.

szokodiakos avatar szokodiakos commented on July 20, 2024

Hello!

Thanks for your interest in Typegoose. Unfortunately currently field-level index definitions are supported, and to support compound indexes, schema level index definition is required.

It is currently a missing feature, but i will assign this as an enhancement and if I have the time it will be done.

PS: PR-s are also appreciated!

Akos

from typegoose.

carmas123 avatar carmas123 commented on July 20, 2024

@kevin-frugier
How can I use your fork in my package.json?
I got an error when I use
"typegoose": "git+https://github.com/kevin-frugier/typegoose.git"

from typegoose.

paul42 avatar paul42 commented on July 20, 2024

would it be possible to create an @Index() decorator, but for the class level? I wouldn't mind taking a stab at a PR, but I'd need to learn a lot about decorators

from typegoose.

hasezoey avatar hasezoey commented on July 20, 2024

thanks to #188 this can be closed

@Ben305

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.