fix(curriculum): Convert blockquote elements to triple backtick syntax for Apis And Microservices (#35996)
* fix: converted blockquotes * fix: revert to blockquote * fix: changed js to http Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: reverted back to blockquote * fix: reverted back to blockquote * fix: reverted back to blockquote
This commit is contained in:
@ -14,14 +14,17 @@ A model allows you to create instances of your objects, called documents.
|
||||
|
||||
Glitch is a real server, and in real servers the interactions with the db happen in handler functions. These function are executed when some event happens (e.g. someone hits an endpoint on your API). We’ll follow the same approach in these exercises. The <code>done()</code> function is a callback that tells us that we can proceed after completing an asynchronous operation such as inserting, searching, updating or deleting. It’s following the Node convention and should be called as <code>done(null, data)</code> on success, or <code>done(err)</code> on error.
|
||||
Warning - When interacting with remote services, errors may occur!
|
||||
<blockquote>
|
||||
/* Example */<br><br>
|
||||
var someFunc = function(done) {<br>
|
||||
//... do something (risky) ...<br>
|
||||
if(error) return done(error);<br>
|
||||
done(null, result);<br>
|
||||
|
||||
```js
|
||||
/* Example */
|
||||
|
||||
var someFunc = function(done) {
|
||||
//... do something (risky) ...
|
||||
if(error) return done(error);
|
||||
done(null, result);
|
||||
};
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
|
@ -12,13 +12,16 @@ In this challenge you will have to create and save a record of a model.
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
Create a document instance using the <code>Person</code> constructor you built before. Pass to the constructor an object having the fields <code>name</code>, <code>age</code>, and <code>favoriteFoods</code>. Their types must conform to the ones in the Person Schema. Then call the method <code>document.save()</code> on the returned document instance. Pass to it a callback using the Node convention. This is a common pattern, all the following CRUD methods take a callback function like this as the last argument.
|
||||
<blockquote>
|
||||
/* Example */<br><br>
|
||||
// ...<br>
|
||||
person.save(function(err, data) {<br>
|
||||
// ...do your stuff here...<br>
|
||||
|
||||
```js
|
||||
/* Example */
|
||||
|
||||
// ...
|
||||
person.save(function(err, data) {
|
||||
// ...do your stuff here...
|
||||
});
|
||||
</blockquote>
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
|
Reference in New Issue
Block a user