Autosave: 2024-06-15 11:15:03
This commit is contained in:
parent
6b5e7c745a
commit
de8ab6ec6d
21 changed files with 49 additions and 24 deletions
|
@ -124,7 +124,7 @@ const Course = mongoose.model(
|
|||
|
||||
Now we need to rewrite our RESTful request handlers so that the data is sourced
|
||||
from and added to the database. We will mainly be using the Mongo syntax defined
|
||||
at [Querying a collection](Querying_a_collection.md) and
|
||||
at [Querying a collection](Querying_a_Mongo_collection.md) and
|
||||
[Adding documents to a collection](Adding_documents_to_a_Mongo_collection.md).
|
||||
We will also keep API validation within the `/model/` file.
|
||||
|
||||
|
@ -176,7 +176,7 @@ router.post("/", async (req, res) => {
|
|||
### PUT
|
||||
|
||||
When updating a value in the database we are going to use the
|
||||
[query-first](Update_document.md#query-first-document-update)
|
||||
[query-first](Update_a_Mongo_document.md#query-first-document-update)
|
||||
approach to updating a Mongo document.
|
||||
|
||||
```jsconst courseSchema = new mongoose.Schema({
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
tags:
|
||||
- javascript
|
||||
- react
|
||||
- react-hooks
|
||||
---
|
||||
|
||||
# Application state management
|
|
@ -2,7 +2,6 @@
|
|||
tags:
|
||||
- typescript
|
||||
- react
|
||||
- react-hooks
|
||||
---
|
||||
|
||||
# Typing built-in hooks
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
tags: [javascript, react, react-hooks]
|
||||
tags:
|
||||
- javascript
|
||||
- react
|
||||
---
|
||||
|
||||
# Child to parent data flow
|
|
@ -2,8 +2,6 @@
|
|||
tags:
|
||||
- javascript
|
||||
- react
|
||||
- react-classes
|
||||
- react-hooks
|
||||
---
|
||||
|
||||
# Comparing class components to hook-based components
|
|
@ -2,7 +2,6 @@
|
|||
tags:
|
||||
- javascript
|
||||
- react
|
||||
- react-classes
|
||||
---
|
||||
|
||||
# Components and props with class-based components
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
tags:
|
||||
- javascript
|
||||
- react
|
||||
- react-hooks
|
||||
---
|
||||
|
||||
# Components and props with hooks
|
|
@ -11,7 +11,7 @@ tags:
|
|||
## Schema
|
||||
|
||||
In order start adding
|
||||
[collections and documents](Introduction.md) to our database,
|
||||
[collections and documents](MongoDB_Introduction.md) to our database,
|
||||
we use Mongoose's **schema** structure. (This is specific to Mongoose and is not
|
||||
a structure that is a part of Mongo in general.)
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
tags:
|
||||
- javascript
|
||||
- react
|
||||
- react-hooks
|
||||
---
|
||||
|
||||
# Custom hook examples
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
tags: [python, timestamps]
|
||||
tags:
|
||||
- python
|
||||
- time
|
||||
---
|
||||
|
||||
# Dates in Python
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
tags: [mongo-db, node-js, mongoose]
|
||||
tags:
|
||||
- mongo-db
|
||||
- node-js
|
||||
- mongoose
|
||||
- databases
|
||||
---
|
||||
|
||||
# MongoDB: deleting a document from a collection
|
|
@ -1,5 +1,8 @@
|
|||
---
|
||||
tags: [mongo-db, node-js]
|
||||
tags:
|
||||
- mongo-db
|
||||
- node-js
|
||||
- databases
|
||||
---
|
||||
|
||||
# Importing data to MongoDB
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
tags: [mongo-db, node-js, mongoose]
|
||||
tags:
|
||||
- mongo-db
|
||||
- node-js
|
||||
- mongoose
|
||||
- databases
|
||||
---
|
||||
|
||||
# Modelling relationships between data
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
tags: [mongo-db]
|
||||
tags:
|
||||
- mongo-db
|
||||
- databases
|
||||
---
|
||||
|
||||
# MongoDB: Introduction
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
tags: [mongo-db, node-js, mongoose]
|
||||
tags:
|
||||
- mongo-db
|
||||
- node-js
|
||||
- mongoose
|
||||
- databases
|
||||
---
|
||||
|
||||
# Query a Mongo collection with Mongoose
|
|
@ -3,7 +3,6 @@ tags:
|
|||
- node-js
|
||||
- REST
|
||||
- APIs
|
||||
- mongo-db
|
||||
---
|
||||
|
||||
# Structuring Express applications
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
---
|
||||
id: l29u
|
||||
title: Time_and_computers
|
||||
tags: [unix]
|
||||
tags:
|
||||
- unix
|
||||
- time
|
||||
created: Sunday, April 28, 2024
|
||||
---
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
---
|
||||
tags: [python, types]
|
||||
tags:
|
||||
- python
|
||||
- data-types
|
||||
---
|
||||
|
||||
# Type hinting in Python
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
tags: [mongo-db, node-js, mongoose]
|
||||
tags:
|
||||
- mongo-db
|
||||
- node-js
|
||||
- mongoose
|
||||
- databases
|
||||
---
|
||||
|
||||
# Update a MongoDB document
|
||||
|
@ -12,7 +16,7 @@ There are two methods for updating a document
|
|||
## Query first document update
|
||||
|
||||
With this approach we first execute a
|
||||
[query](Querying_a_collection.md) to retrieve the document we
|
||||
[query](Querying_a_Mongo_collection.md) to retrieve the document we
|
||||
want to edit and then make the change. We use the `findById` method to identify
|
||||
the document by its UUID and then `set` to update specified properties on the
|
||||
document. The `set` method is one of many operators that can be used to update
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
tags: [mongo-db, mongoose, node-js]
|
||||
tags:
|
||||
- mongo-db
|
||||
- mongoose
|
||||
- node-js
|
||||
- databases
|
||||
---
|
||||
|
||||
# Validating Mongoose schemas
|
||||
|
|
|
@ -124,4 +124,4 @@ Then, in our code we just insert the `Context` component:
|
|||
In the examples above we have only been consuming state that is owned by the
|
||||
provider however in most scenarios you will also want to update the state from a
|
||||
consumer. This is best achieved by combining `useContext` with a reducer and is
|
||||
detailed in [Application state management](Application_state_management.md).
|
||||
detailed in [Application state management](Application_state_management_with_React_hooks.md).
|
||||
|
|
Loading…
Add table
Reference in a new issue