Попытка реализовать модель Mongoose в Typescript. Очистка Google выявила только гибридный подход (сочетающий JS и TS). Как можно было бы реализовать класс User, по моему довольно наивному подходу, без JS?
Хотите, чтобы IUserModel без багажа.
import {IUser} from './user.ts';
import {Document, Schema, Model} from 'mongoose';
// mixing in a couple of interfaces
interface IUserDocument extends IUser, Document {}
// mongoose, why oh why '[String]'
// TODO: investigate out why mongoose needs its own data types
let userSchema: Schema = new Schema({
userName : String,
password : String,
firstName : String,
lastName : String,
email : String,
activated : Boolean,
roles : [String]
});
// interface we want to code to?
export interface IUserModel extends Model<IUserDocument> {/* any custom methods here */}
// stumped here
export class User {
constructor() {}
}