Autosave: 2024-06-15 11:15:03

This commit is contained in:
thomasabishop 2024-06-15 11:15:03 +01:00
parent 6b5e7c745a
commit de8ab6ec6d
21 changed files with 49 additions and 24 deletions

View file

@ -124,7 +124,7 @@ const Course = mongoose.model(
Now we need to rewrite our RESTful request handlers so that the data is sourced 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 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). [Adding documents to a collection](Adding_documents_to_a_Mongo_collection.md).
We will also keep API validation within the `/model/` file. We will also keep API validation within the `/model/` file.
@ -176,7 +176,7 @@ router.post("/", async (req, res) => {
### PUT ### PUT
When updating a value in the database we are going to use the 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. approach to updating a Mongo document.
```jsconst courseSchema = new mongoose.Schema({ ```jsconst courseSchema = new mongoose.Schema({

View file

@ -2,7 +2,6 @@
tags: tags:
- javascript - javascript
- react - react
- react-hooks
--- ---
# Application state management # Application state management

View file

@ -2,7 +2,6 @@
tags: tags:
- typescript - typescript
- react - react
- react-hooks
--- ---
# Typing built-in hooks # Typing built-in hooks

View file

@ -1,5 +1,7 @@
--- ---
tags: [javascript, react, react-hooks] tags:
- javascript
- react
--- ---
# Child to parent data flow # Child to parent data flow

View file

@ -2,8 +2,6 @@
tags: tags:
- javascript - javascript
- react - react
- react-classes
- react-hooks
--- ---
# Comparing class components to hook-based components # Comparing class components to hook-based components

View file

@ -2,7 +2,6 @@
tags: tags:
- javascript - javascript
- react - react
- react-classes
--- ---
# Components and props with class-based components # Components and props with class-based components

View file

@ -2,7 +2,6 @@
tags: tags:
- javascript - javascript
- react - react
- react-hooks
--- ---
# Components and props with hooks # Components and props with hooks

View file

@ -11,7 +11,7 @@ tags:
## Schema ## Schema
In order start adding 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 we use Mongoose's **schema** structure. (This is specific to Mongoose and is not
a structure that is a part of Mongo in general.) a structure that is a part of Mongo in general.)

View file

@ -2,7 +2,6 @@
tags: tags:
- javascript - javascript
- react - react
- react-hooks
--- ---
# Custom hook examples # Custom hook examples

View file

@ -1,5 +1,7 @@
--- ---
tags: [python, timestamps] tags:
- python
- time
--- ---
# Dates in Python # Dates in Python

View file

@ -1,5 +1,9 @@
--- ---
tags: [mongo-db, node-js, mongoose] tags:
- mongo-db
- node-js
- mongoose
- databases
--- ---
# MongoDB: deleting a document from a collection # MongoDB: deleting a document from a collection

View file

@ -1,5 +1,8 @@
--- ---
tags: [mongo-db, node-js] tags:
- mongo-db
- node-js
- databases
--- ---
# Importing data to MongoDB # Importing data to MongoDB

View file

@ -1,5 +1,9 @@
--- ---
tags: [mongo-db, node-js, mongoose] tags:
- mongo-db
- node-js
- mongoose
- databases
--- ---
# Modelling relationships between data # Modelling relationships between data

View file

@ -1,5 +1,7 @@
--- ---
tags: [mongo-db] tags:
- mongo-db
- databases
--- ---
# MongoDB: Introduction # MongoDB: Introduction

View file

@ -1,5 +1,9 @@
--- ---
tags: [mongo-db, node-js, mongoose] tags:
- mongo-db
- node-js
- mongoose
- databases
--- ---
# Query a Mongo collection with Mongoose # Query a Mongo collection with Mongoose

View file

@ -3,7 +3,6 @@ tags:
- node-js - node-js
- REST - REST
- APIs - APIs
- mongo-db
--- ---
# Structuring Express applications # Structuring Express applications

View file

@ -1,7 +1,9 @@
--- ---
id: l29u id: l29u
title: Time_and_computers title: Time_and_computers
tags: [unix] tags:
- unix
- time
created: Sunday, April 28, 2024 created: Sunday, April 28, 2024
--- ---

View file

@ -1,5 +1,7 @@
--- ---
tags: [python, types] tags:
- python
- data-types
--- ---
# Type hinting in Python # Type hinting in Python

View file

@ -1,5 +1,9 @@
--- ---
tags: [mongo-db, node-js, mongoose] tags:
- mongo-db
- node-js
- mongoose
- databases
--- ---
# Update a MongoDB document # Update a MongoDB document
@ -12,7 +16,7 @@ There are two methods for updating a document
## Query first document update ## Query first document update
With this approach we first execute a 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 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 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 document. The `set` method is one of many operators that can be used to update

View file

@ -1,5 +1,9 @@
--- ---
tags: [mongo-db, mongoose, node-js] tags:
- mongo-db
- mongoose
- node-js
- databases
--- ---
# Validating Mongoose schemas # Validating Mongoose schemas

View file

@ -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 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 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 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).