Skip to content

Commit acbd5c8

Browse files
committed
4c fin synch with en
1 parent f52c1a4 commit acbd5c8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/content/4/fi/osa4c.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,25 @@ notesRouter.post('/', async (request, response) => {
439439
})
440440
```
441441

442+
Muistiinpanon skeema muuttuu myös hieman:
443+
444+
```js
445+
const noteSchema = new mongoose.Schema({
446+
content: {
447+
type: String,
448+
required: true,
449+
minlength: 5
450+
},
451+
important: Boolean,
452+
// highlight-start
453+
user: {
454+
type: mongoose.Schema.Types.ObjectId,
455+
ref: 'User'
456+
}
457+
//highlight-end
458+
})
459+
```
460+
442461
Huomionarvoista on nyt se, että myös <i>user</i>-olio muuttuu. Sen kenttään <i>notes</i> talletetaan luodun muistiinpanon <i>id</i>:
443462
Koska tieto tallennetaan <i>user</i>-olioon tulee muistiinpanoa poistettaessa tieto poistaa myös <i>user</i>-olion listalta.
444463

0 commit comments

Comments
 (0)