src/db/models/point.ts:10:11 - error TS2693: 'number' only refers to a type, but is being used as a value here.
const PointSchema: Schema = new Schema({
id: {
type: String,
required: true,
unique: true,
index: true,
},
point: {
type: number,
required: true,
},
});
export interface PointProp extends Document {
id: string;
point: number;
}
export default model<PointProp>('point', PointSchema);
CodePudding user response:
You are using a TypeScript type
inside an object, as value, just as what the error says. You should have given more info, but I am guessing you are working with Mongoose. In that case, number
(the TypeScript type) should be Number (the object)
const PointSchema: Schema = new Schema({
id: {
type: String,
required: true,
unique: true,
index: true,
},
point: {
type: Number, // <---
required: true,
},
});
See https://mongoosejs.com/docs/guide.html#definition for more information.