-
Notifications
You must be signed in to change notification settings - Fork 11
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
findOne.cache is not a function #2
Comments
have you already test without The common case is, maybe your |
The query has been working and in production for a good while. It is just the addition of import mongoose, { Schema, Document } from 'mongoose';
import { createModel } from '../utils/mongoose-utils';
import IPerson from '../interfaces/IPerson';
interface IPersonDB extends IPerson, Document { }
const personSchema = new Schema({
name: {
type: String,
required: true
},
title: {
type: String
},
language: {
type: String,
default: 'en',
lowercase: true
},
mobile: {
type: String,
unique: true,
sparse: true,
lowercase: true,
trim: true,
index: true,
set: value => (value === '' ? undefined : value)
},
email: {
type: String,
unique: true,
sparse: true,
lowercase: true,
trim: true,
index: true,
set: value => (value === '' ? undefined : value)
},
timezone: String
}, {
timestamps: true
});
});
export default createModel<IPersonDB>('Person', personSchema); The source for function createModel<T extends Document> (schemaName: string, schema: Schema): Model<T> {
let model = mongoose.connection.models[schemaName];
if (!model) {
model = mongoose.model(schemaName, schema);
}
return model;
} |
I'll check this.. |
I am wondering whether the dynamic import is causing issues with the models and this package. I'll need to investigate. |
I am having trouble using this, with the following error being generated:
The database initialisation code:
Then in use:
I do notice the result type for
findOne()
isDocumentQuery
.Any ideas as to what could be causing this?
Environment
The text was updated successfully, but these errors were encountered: