rsnext/examples/with-mongodb-mongoose/models/Pet.ts
Steven 4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00

71 lines
1.6 KiB
TypeScript

import mongoose from "mongoose";
export interface Pets extends mongoose.Document {
name: string;
owner_name: string;
species: string;
age: number;
poddy_trained: boolean;
diet: string[];
image_url: string;
likes: string[];
dislikes: string[];
}
/* PetSchema will correspond to a collection in your MongoDB database. */
const PetSchema = new mongoose.Schema<Pets>({
name: {
/* The name of this pet */
type: String,
required: [true, "Please provide a name for this pet."],
maxlength: [60, "Name cannot be more than 60 characters"],
},
owner_name: {
/* The owner of this pet */
type: String,
required: [true, "Please provide the pet owner's name"],
maxlength: [60, "Owner's Name cannot be more than 60 characters"],
},
species: {
/* The species of your pet */
type: String,
required: [true, "Please specify the species of your pet."],
maxlength: [40, "Species specified cannot be more than 40 characters"],
},
age: {
/* Pet's age, if applicable */
type: Number,
},
poddy_trained: {
/* Boolean poddy_trained value, if applicable */
type: Boolean,
},
diet: {
/* List of dietary needs, if applicable */
type: [String],
},
image_url: {
/* Url to pet image */
required: [true, "Please provide an image url for this pet."],
type: String,
},
likes: {
/* List of things your pet likes to do */
type: [String],
},
dislikes: {
/* List of things your pet does not like to do */
type: [String],
},
});
export default mongoose.models.Pet || mongoose.model<Pets>("Pet", PetSchema);