-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
When I try to insert a document using a template, I get the following error message
error: Uncaught (in promise) Error: Error in insertOne function. Error: No connection established before query.
app-back-1 | throw new Error(`Error in insertOne function. ${error}`);
app-back-1 | ^
app-back-1 | at Model.insertOne (https://deno.land/x/dangodb@v1.0.2/lib/query.ts:440:13)
app-back-1 | at file:///usr/src/packages/back/main.ts:15:17
code: main.ts
await dango.connect(Deno.env.get("MONGO_URL") || "mongodb://localhost:27017");
await UserModel.insertOne({
name: "Praveen",
email: "",
password: "",
role: {
admin: false
}
});
Schema & model: models/user.ts
import {dango} from "dangoDB"
const userSchema = dango.schema({
name: {
type: "string",
required: true
},
email: {
type: "string",
required: true,
unique: true,
validator: (value: string) => {
return /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(value);
}
},
password: {
type: "string",
required: true,
},
role: {
type: "object",
required: true,
properties: {
admin: {
type: "boolean",
required: true,
default: false
}
}
},
createdAt: {
type: "date",
required: true,
default: new Date()
}
})
const UserModel = dango.model("User", userSchema);
export default UserModel;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels