import { model, Schema } from "mongoose"; export interface PostingType { title: string; text?: string; theme: string; city: string; username?: string; } const postingSchema = new Schema( { title: { type: String, required: true, }, text: { type: String, required: true, }, theme: { type: String, }, city: { type: String, }, username: { type: String, }, } // username 때문에 duplicate key error 발생 ); export default model("Posting", postingSchema);