Comments (5)
have you already test without .cache
? is your model query working or not?
The common case is, maybe your model.js
is not passing as Model but as Document, so it is better if you show to us your model.js here.
from recachegoose.
The query has been working and in production for a good while. It is just the addition of .cache
which is proving problematic. The code is as follows:
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 createModel
:
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;
}
from recachegoose.
I'll check this..
from recachegoose.
I have test this with npm test and also in my production server mongodb version 5, everything running well.
I add some test to make sure Record.findOne is having a function.
As you can see in this image below here..
See at line 408, there was already function to test get one document.
And the result is fine.
My Environment:
- Mongo Server: 5.0
- Mongoose: 5.0.1
- OS: Ubuntu 18
from recachegoose.
I am wondering whether the dynamic import is causing issues with the models and this package. I'll need to investigate.
from recachegoose.
Related Issues (3)
- Typescript support HOT 4
- Cache returning invalid document HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recachegoose.