-
-
Save edgarbs1998/75342511e9cdf8eb4f6f9cdcffa19c19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { model, Schema, connect } = require("mongoose"); | |
const { MongoMemoryServer } = require("mongodb-memory-server"); | |
interface User { | |
name: string; | |
} | |
const UserSchema = new Schema<User>({ | |
name: { type: String, required: true }, | |
}); | |
export const UserModel = model<User>("User", UserSchema); | |
async function test() { | |
const mongod = await MongoMemoryServer.create(); | |
connect(mongod.getUri()); | |
await UserModel.create({ name: "edgar" }); | |
const result = await UserModel.find() | |
.map((docs: any) => { | |
return docs; | |
}) | |
.exec(); | |
console.dir(result); | |
} | |
test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment