# Mongodb create model

**URL:** <https://forum.freecodecamp.org/t/mongodb-create-model/500685>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [March 13, 2022, 6:21pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685 "2022-03-13T18:21:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmnqv123](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jmnqv123/32/142747_2.png) [@jmnqv123](https://forum.freecodecamp.org/u/jmnqv123)\
**Post date:** [March 13, 2022, 6:21pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/1 "2022-03-13T18:21:21Z")

</div>

**Tell us what’s happening:**  
Describe your issue in detail here.  
Creating an instance from a mongoose schema should succeed  
my code:

```auto
const Schema = mongoose.Schema;
const personSchema = new Schema({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods:[{ String
                 
}]});
const Person = mongoose.model("Person", personSchema);

```

**Your project link(s)**

solution: [Glitch Blog](https://glitch.com/edit/#!/spectrum-childish-beret)

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36`

**Challenge:** Create a Model

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/back-end-development-and-apis/mongodb-and-mongoose/create-a-model)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 13, 2022, 6:33pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/2 "2022-03-13T18:33:35Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 13, 2022, 6:34pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/3 "2022-03-13T18:34:18Z")

</div>

> [@jmnqv123](#):
>
> Describe your issue in detail here.  
> Creating an instance from a mongoose schema should succeed

What about the instructions are confusing to you? Where did you get stuck?

---

<div class="post-metadata">

**Author:** ![jmnqv123](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jmnqv123/32/142747_2.png) [@jmnqv123](https://forum.freecodecamp.org/u/jmnqv123)\
**Post date:** [March 13, 2022, 6:36pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/4 "2022-03-13T18:36:49Z")

</div>

```auto
const Schema = mongoose.Schema;
const personSchema = new Schema({
  name: { type: String, required: true },
  age: Number,
  favoriteFoods: [String]
});
const Person = mongoose.model("Person", personSchema);

```

iv typed in it says  
Creating an instance from a mongoose schema should succeed

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 13, 2022, 6:37pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/5 "2022-03-13T18:37:53Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 13, 2022, 6:38pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/6 "2022-03-13T18:38:47Z")

</div>

That’s literally what you said in the first post. That gives zero additional information.

What debugging have you tried?

This is deep enough in the curriculum that you really need some debugging skills to be successful. Just handing wrong code and an error message to someone and expecting them to debug for you won’t work very well as you progress. We need more data to help more effectively and you need to practice debugging and technical communication skills to be more effective as a developer.

Do you get any errors when you run the code manually? Can you put in a console log to see what output you are getting?

---

<div class="post-metadata">

**Author:** ![jmnqv123](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jmnqv123/32/142747_2.png) [@jmnqv123](https://forum.freecodecamp.org/u/jmnqv123)\
**Post date:** [March 14, 2022, 5:04am UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/7 "2022-03-14T05:04:41Z")

</div>

I’ve debugged it gives error plz could u provide me the solution

---

<div class="post-metadata">

**Author:** ![jmnqv123](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jmnqv123/32/142747_2.png) [@jmnqv123](https://forum.freecodecamp.org/u/jmnqv123)\
**Post date:** [March 14, 2022, 5:05am UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/8 "2022-03-14T05:05:23Z")

</div>

I’ve tried everything plz Cul u provide me the solution

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [March 14, 2022, 5:12am UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/9 "2022-03-14T05:12:24Z")

</div>

We don’t write answers for users.

It’s hard to debug “I tried everything”. What is “everything”?

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [March 14, 2022, 11:36am UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/10 "2022-03-14T11:36:19Z")

</div>

You are not using the correct [starter boilerplate](https://github.com/freeCodeCamp/boilerplate-mongomongoose/).

> **[Importing Code from GitHub to Glitch](https://help.glitch.com/kb/article/20-importing-code-from-github/)**
>
> Yes! You can import your code from GitHub into your Glitch project! Here's how...

---

<div class="post-metadata">

**Author:** ![edper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/edper/32/108280_2.png) [@edper](https://forum.freecodecamp.org/u/edper)\
**Post date:** [March 17, 2022, 7:15am UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/11 "2022-03-17T07:15:15Z")

</div>

You have problem probably in the first line of your code here.

Check the documentation for [Mongoose Schemas (mongoosejs.com)](https://mongoosejs.com/docs/guide.html#definition) and compare to yours.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 15, 2022, 7:15pm UTC](https://forum.freecodecamp.org/t/mongodb-create-model/500685/12 "2022-09-15T19:15:27Z")

</div>

Closed on September 15, 2022, 7:15pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
