remove mkdocs specific syntax

This commit is contained in:
Marcello 2024-06-16 19:14:59 +02:00
parent 8d08c1964f
commit 8026e1465b
Signed by: m-lamonaca
SSH key fingerprint: SHA256:8db8uii6Gweq7TbKixFBioW2T8CbgtyFETyYL3cr3zk
77 changed files with 1128 additions and 1128 deletions

View file

@ -25,7 +25,7 @@ MongoDB automatically creates an `ObjectId()` if it's not provided.
To create a database is sufficient to switch towards a non existing one with `use <database>` (implicit creation).
The database is not actually created until a document is inserted.
```sh linenums="1"
```sh
show dbs # list all databases
use <database> # use a particular database
show collections # list all collection for the current database
@ -38,7 +38,7 @@ db.<collection>.insertOne({document}) # implicit collection creation
## Operators (MQL Syntax)
```json linenums="1"
```json
/* --- Update operators --- */
{ "$inc": { "<key>": "<increment>", ... } } // increment value
{ "$set": { "<key>": "<value>", ... } } // set value
@ -83,7 +83,7 @@ db.<collection>.insertOne({document}) # implicit collection creation
> **Note**: `$<key>` is used to access the value of the field dynamically
```json linenums="1"
```json
{ "$expr": { "<expression>" } } // aggregation expression, variables, conditional expressions
{ "$expr": { "$<comparison_operator>": [ "$<key>", "$<key>" ] } } // compare field values (operators use aggregation syntax)
```
@ -99,7 +99,7 @@ Insertion results:
- error -> rollback
- success -> entire documents gets saved
```sh linenums="1"
```sh
# explicit collection creation, all options are optional
db.createCollection( <name>,
{
@ -132,7 +132,7 @@ db.<collection>.insertMany([ { document }, { document } ] , { "ordered": false }
### Querying
```sh linenums="1"
```sh
db.<collection>.findOne() # find only one document
db.<collection>.find(filter) # show selected documents
db.<collection>.find().pretty() # show documents formatted
@ -176,7 +176,7 @@ db.<collection>.find().hint( { $natural : -1 } ) # force the query to perform a
[Update Operators](https://docs.mongodb.com/manual/reference/operator/update/ "Update Operators Documentation")
```sh linenums="1"
```sh
db.<collection>.replaceOne(filter, update, options)
db.<collection>.updateOne(filter, update, {upsert: true}) # modify document if existing, insert otherwise
@ -185,7 +185,7 @@ db.<collection>.updateOne(filter, { "$push": { ... }, "$set": { ... }, { "$inc":
### Deletion
```sh linenums="1"
```sh
db.<collection>.deleteOne(filter, options)
db.<collection>.deleteMany(filter, options)
@ -203,7 +203,7 @@ Utility to import all docs into a specified collection.
If the collection already exists `--drop` deletes it before reuploading it.
**WARNING**: CSV separators must be commas (`,`)
```sh linenums="1"
```sh
mongoimport <options> <connection-string> <file>
--uri=<connectionString>
@ -222,7 +222,7 @@ mongoimport <options> <connection-string> <file>
Utility to export documents into a specified file.
```sh linenums="1"
```sh
mongoexport --collection=<collection> <options> <connection-string>
--uri=<connectionString>
@ -276,7 +276,7 @@ Indexes _slow down writing operations_ since the index must be updated at every
### Diagnosis and query planning
```sh linenums="1"
```sh
db.<collection>.find({...}).explain() # explain won't accept other functions
db.explain().<collection>.find({...}) # can accept other functions
db.explain("executionStats").<collection>.find({...}) # more info
@ -284,7 +284,7 @@ db.explain("executionStats").<collection>.find({...}) # more info
### Index Creation
```sh linenums="1"
```sh
db.<collection>.createIndex( <key and index type specification>, <options> )
db.<collection>.createIndex( { "<key>": <type>, "<key>": <type>, ... } ) # normal, compound or multikey (field is array) index
@ -306,7 +306,7 @@ db.<collection>.createIndex(
### [Index Management](https://docs.mongodb.com/manual/tutorial/manage-indexes/)
```sh linenums="1"
```sh
# view all db indexes
db.getCollectionNames().forEach(function(collection) {
indexes = db[collection].getIndexes();
@ -343,7 +343,7 @@ handling connections, requests and persisting the data.
### Basic Shell Helpers
```sh linenums="1"
```sh
db.<method>() # database interaction
db.<collection>.<method>() # collection interaction
rs.<method>(); # replica set deployment and management
@ -382,7 +382,7 @@ Log Verbosity Level:
- `0`: Default Verbosity (Information)
- `1 - 5`: Increases the verbosity up to Debug messages
```sh linenums="1"
```sh
db.getLogComponents() # get components and their verbosity
db.adminCommand({"getLog": "<scope>"}) # retrieve logs (getLog must be run on admin db -> adminCommand)
db.setLogLevel(<level>, "<component>"); # set log level (output is OLD verbosity levels)
@ -408,7 +408,7 @@ Events captured by the profiler:
> **Note**: Logs are saved in the `system.profile` _capped_ collection.
```sh linenums="1"
```sh
db.setProfilingLevel(n) # set profiler level
db.setProfilingLevel(1, { slowms: <ms> })
db.getProfilingStatus() # check profiler status
@ -456,7 +456,7 @@ Built-in Roles Groups and Names:
- Backup/Restore: `backup`, `restore`
- Super User: `root`
```sh linenums="1"
```sh
db.createUser({
user: "<username>",
pwd: "<password>",
@ -538,7 +538,7 @@ Variable syntax in aggregations:
Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ "$match": { "<query>" } },
@ -570,7 +570,7 @@ Passes along the documents with the requested fields to the next stage in the pi
- [`$sum`][$sum_docs]
- [`$avg`][$avg_docs]
```sh linenums="1"
```sh
db.<collection>.aggregate([
{
"$project": {
@ -627,7 +627,7 @@ db.<collection>.aggregate([
Adds new fields to documents (can be result of computation).
`$addFields` outputs documents that contain _all existing fields_ from the input documents and newly added fields.
```sh linenums="1"
```sh
db.<collection>.aggregate({
{ $addFields: { <newField>: <expression>, ... } }
})
@ -639,7 +639,7 @@ db.<collection>.aggregate({
The $`group` stage separates documents into groups according to a "group key". The output is one document for each unique group key.
```sh linenums="1"
```sh
db.<collection>.aggregate([
{
"$group": {
@ -658,7 +658,7 @@ db.<collection>.aggregate([
Deconstructs an array field from the input documents to output a document for each element.
Each output document is the input document with the value of the array field replaced by the element
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ "$unwind": "<array-key>" }
@ -676,7 +676,7 @@ db.<collection>.aggregate([
### [`$count` Aggregation Stage][$count_docs]
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ "$count": "<count-key>" }
])
@ -686,7 +686,7 @@ db.<collection>.aggregate([
### [`$sort` Aggregation Stage][$sort_docs]
```sh linenums="1"
```sh
db.<collection>.aggregate([
{
"$sort": {
@ -705,7 +705,7 @@ db.<collection>.aggregate([
### [`$skip` Aggregation Stage][$skip_docs]
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ "$skip": "<positive 64-bit integer>" }
])
@ -715,7 +715,7 @@ db.<collection>.aggregate([
### [`$limit` Aggregation Stage][$limit_docs]
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ "$limit": "<positive 64-bit integer>" }
])
@ -730,7 +730,7 @@ The `$lookup` stage adds a new array field to each input document. The new array
> **Note**: To combine elements from two different collections, use the [`$unionWith`][$unionWith_docs] pipeline stage.
```sh linenums="1"
```sh
db.<collection>.aggregate([
{
"$lookup": {
@ -753,7 +753,7 @@ Performs a recursive search on a collection, with options for restricting the se
The collection on which the aggregation is performed and the `from` collection can be the same (in-collection search) or different (cross-collection search)
```sh linenums="1"
```sh
db.<collection>.aggregate([
{
$graphLookup: {
@ -783,7 +783,7 @@ Each output document contains two fields: an `_id` field containing the distinct
The documents are sorted by count in descending order.
```sh linenums="1"
```sh
db.<collection>.aggregate([
{ $sortByCount: <expression> }
])

View file

@ -10,14 +10,14 @@ Often Redis it is called a *data structure* server because it has outer key-valu
### Server Startup
```bash linenums="1"
```bash
redis-server # start the server
redis-cli
```
### [Key-Value Pairs](https://redis.io/commands#generic)
```sh linenums="1"
```sh
SET <key> <value> [ EX <seconds> ] # store a key-value pair, TTL optional
GET <key> # read a key content
EXISTS <key> # check if a key exists
@ -40,7 +40,7 @@ PERSIST <key> # make the key permanent
A list is a series of ordered values.
```sh linenums="1"
```sh
RPUSH <key> <value1> <value2> ... # add one or more values to the end of the list
LPUSH <key> <value1> <value2> ... # add one or more values to the start of a list
@ -55,7 +55,7 @@ RPOP # remove and return the last item fro the list
A set is similar to a list, except it does not have a specific order and each element may only appear once.
```sh linenums="1"
```sh
SADD <key> <value1> <value2> ... # add one or more values to the set (return 0 if values are already inside)
SREM <key> <value> # remove the given member from the set, return 1 or 0 to signal if the member was actually there or not.
SPOP <key> <value> # remove and return value from the set
@ -72,7 +72,7 @@ Sets are a very handy data type, but as they are unsorted they don't work well f
A sorted set is similar to a regular set, but now each value has an associated score. This score is used to sort the elements in the set.
```sh linenums="1"
```sh
ZADD <key> <score> <value> # add a value with it's score
ZRANGE <key> <start_index> <end_index> # return a subset of the sortedSet
@ -84,7 +84,7 @@ ZRANGE <key> <start_index> <end_index> # return a subset of the sortedSet
Hashes are maps between string fields and string values, so they are the perfect data type to represent objects.
```sh linenums="1"
```sh
HSET <key> <field> <value> [ <field> <value> ... ] # set the string of a hash field
HSETNX <key> <field> <value> # set the value of a hash field, only if the field does not exist

View file

@ -2,7 +2,7 @@
## DDL
```sql linenums="1"
```sql
show databases; -- mostra database
CREATE DATABASE <database>; -- database creation
use <database_name>; -- usa un database particolare
@ -16,7 +16,7 @@ show tables; -- mostra tabelle del database
### Table Creation
```sql linenums="1"
```sql
CREATE TABLE <table_name>
(<field_name> <field_type> <option>,
...);
@ -24,7 +24,7 @@ CREATE TABLE <table_name>
### PRIMARY KEY from multiple fields
```sql linenums="1"
```sql
CREATE TABLE <table_name>(
...,
PRIMARY KEY (<field1>, ...),
@ -33,7 +33,7 @@ CREATE TABLE <table_name>(
### Table Field Options
```sql linenums="1"
```sql
PRIMARY KEY -- marks primary key as field option
NOT NULL -- marks a necessary field
REFERENCES <table> (<field>) -- adds foreign key reference
@ -43,7 +43,7 @@ UNIQUE (<field>) -- set field as unique (MySQL)
### Table Modification
```sql linenums="1"
```sql
ALTER TABLE <table>
ADD PRIMARY KEY (<field>, ...), -- definition of PK after table creation
ADD <field_name> <field_type> <option>; -- addition of a new field, field will have no value in the table
@ -63,20 +63,20 @@ ALTER TABLE <table>
### Data Insertion
```sql linenums="1"
```sql
INSERT INTO <table> (field_1, ...) VALUES (value_1, ...), (value_1, ...);
INSERT INTO <table> VALUES (value_1, ...), (value_1, ...); -- field order MUST respect tables's columns order
```
### Data Update
```sql linenums="1"
```sql
UPDATE <table> SET <field> = <value>, <field> = <value>, ... WHERE <condition>;
```
### Data Elimination
```sql linenums="1"
```sql
DELETE FROM <table> WHERE <condition>
DELETE FROM <table> -- empty the table
```
@ -85,7 +85,7 @@ DELETE FROM <table> -- empty the table
`*`: denotes all table fields
```sql linenums="1"
```sql
SELECT * FROM <table>; -- show table contents
SHOW columns FROM <table>; -- show table columns
DESCRIBE <table>; -- shows table
@ -93,13 +93,13 @@ DESCRIBE <table>; -- shows table
### Alias
```sql linenums="1"
```sql
SELECT <field> as <alias>; -- shows <field/funzione> with name <alias>
```
### Conditional Selection
```sql linenums="1"
```sql
SELECT * FROM <table> WHERE <condition>; -- shows elements that satisfy the condition
AND, OR, NOT -- logic connectors
@ -108,7 +108,7 @@ SELECT * FROM <table> WHERE <field> Between <value_1> AND <value_2>;
### Ordering
```sql linenums="1"
```sql
SELECT * FROM <table> ORDER BY <field>, ...; -- shows the table ordered by <field>
SELECT * FROM <table> ORDER BY <field>, ... DESC; -- shows the table ordered by <field>, decreasing order
SELECT * FROM <table> ORDER BY <field>, ... LIMIT n; -- shows the table ordered by <field>, shows n items
@ -117,7 +117,7 @@ SELECT TOP(n) * FROM <table> ORDER BY <field>, ...; -- T-SQL
## Grouping
```sql linenums="1"
```sql
SELECT * FROM <table> GROUP BY <field>;
SELECT * FROM <table> GROUP BY <field> HAVING <condition>;
SELECT DISTINCT <field> FROM <table>; -- shows elements without repetitions
@ -127,7 +127,7 @@ SELECT DISTINCT <field> FROM <table>; -- shows elements without repetitions
`%`: any number of characters
```sql linenums="1"
```sql
SELECT * FROM <table> WHERE <field> LIKE '<char>%'; -- selects items in <field> that start with <char>
SELECT * FROM <table> WHERE <field> LIKE '%<char>'; -- selects items in <field> that end with <char>
SELECT * FROM <table> WHERE <field> LIKE '%<char>%'; -- selects items in <field> that contain <char>
@ -136,14 +136,14 @@ SELECT * FROM <table> WHERE <field> NOT LIKE '%<char>%'; -- selects items in
### Selection from multiple tables
```sql linenums="1"
```sql
SELECT a.<field>, b.<field> FROM <table> AS a, <table> AS b
WHERE a.<field> ...;
```
## Functions
```sql linenums="1"
```sql
SELECT COUNT(*) FROM <field>; -- count of items in <field>
SELECT MIN(*) FROM <table>; -- min value
SELECT MAX(*) FROM <table>; -- max value
@ -154,7 +154,7 @@ ANY (SELECT ...)
## Nested Queries
```sql linenums="1"
```sql
SELECT * FROM <table> WHERE EXISTS (SELECT * FROM <table>) -- selected field existing in subquery
SELECT * FROM <table> WHERE NOT EXISTS (SELECT * FROM <table>) -- selected field not existing in subquery
```
@ -163,7 +163,7 @@ SELECT * FROM <table> WHERE NOT EXISTS (SELECT * FROM <table>) -- selected fiel
Create new table with necessary fields:
```sql linenums="1"
```sql
CREATE TABLE <table> (
(<field_name> <field_type> <option>,
...);
@ -172,14 +172,14 @@ CREATE TABLE <table> (
Fill fields with data from table:
```sql linenums="1"
```sql
INSERT INTO <table>
SELECT <fields> FROM <TABLE> WHERE <condition>;
```
## Join
```sql linenums="1"
```sql
SELECT * FROM <table1> JOIN <table2> ON <table1>.<field> = <table2>.<field>;
SELECT * FROM <table1> LEFT JOIN <table2> ON <condition>;
SELECT * FROM <table1> RIGHT JOIN <table2> ON <condition>
@ -189,7 +189,7 @@ SELECT * FROM <table1> RIGHT JOIN <table2> ON <condition>
## Multiple Join
```sql linenums="1"
```sql
SELECT * FROM <table1>
JOIN <table2> ON <table1>.<field> = <table2>.<field>
JOIN <table3> ON <table2>.<field> = <table3>.<field>;
@ -203,7 +203,7 @@ JOIN <table3> ON <table2>.<field> = <table3>.<field>;
### T-SQL Insert From table
```sql linenums="1"
```sql
USE [<db_name>]
SET IDENTITY_INSERT [<destination_table>] ON
@ -217,7 +217,7 @@ SET IDENTITY_INSERT [<destination_table>] OFF
### T-SQL Parametric Query
```sql linenums="1"
```sql
-- variable declaration
DECLARE @var_name <type>
@ -238,7 +238,7 @@ GO
A view represents a virtual table. Join multiple tables in a view and use the view to present the data as if the data were coming from a single table.
```sql linenums="1"
```sql
CREATE VIEW <name> AS
SELECT * FROM <table> ...
```
@ -250,7 +250,7 @@ SELECT * FROM <table> ...
Stored Procedure Definition:
```sql linenums="1"
```sql
CREATE PROCEDURE <Procedure_Name>
-- Add the parameters for the stored procedure here
<@Param1> <Datatype_For_Param1> = <Default_Value_For_Param1>,
@ -268,7 +268,7 @@ GO
Stored Procedure call in query:
```sql linenums="1"
```sql
USE <database>
GO