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

Getting OverwriteModelError #85

Open
canaryGrapher opened this issue May 6, 2022 · 2 comments
Open

Getting OverwriteModelError #85

canaryGrapher opened this issue May 6, 2022 · 2 comments

Comments

@canaryGrapher
Copy link

I keep getting this error when refreshing my Remix application
OverwriteModelError: Cannot overwrite Forms model once compiled.

This is my model

import { createSchema, Type, typedModel } from 'ts-mongoose';
import { Form1Page1Schema } from './forms/form1page1';

export const FormSchema = createSchema(
    {
        user: Type.string({ required: true }),
        isComplete: Type.boolean({ required: true }),
        dateCreated: Type.date({ default: Date.now as any }),
        form1page1: Type.object().of(Form1Page1Schema),
    }
);

export const Form_Model = typedModel('Form_Data', FormSchema);

How do I fix it?

@windward-hive
Copy link

You can fix it by not using this dead package. It's a remarkable package don't get me wrong, but it's dead. Mongoose has since had significant updates and this needs a lot of work to get it to play nicely with mongoose's latest versions

@Nikoms
Copy link

Nikoms commented Aug 20, 2022

@maybesmurf @canaryGrapher I had the same problems, so I just made a simple package to infer document type from schema: https://www.npmjs.com/package/mongoose-schema-ts-infer. I hope it will work for you like it worked for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants