I have 2 files as below
admin.js
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
const Schema = new Schema({
User: { type: String, unique: true },
Pass: { type: String },
});
var Admin = mongoose.model("admin", Schema);
module.exports = Admin;
admin.test.js
const Admin = require('./admin.js');
test("verify username is present and datatype is correct", () => {
if (typeof Admin.Admin !== "undefined") {
// this statement will not execute
console.log('username is DEFINED');
} else {
console.log('username is not DEFINED');
}
});
I need to validate that the Username is present and validate datatype is a string. I am not able to call the Username from another file.