• Skip to main content

Rokturis

Pie kā turēties

  • Full Stack
    • JavaScript
    • JS Snipets
    • CSS
    • Git
    • VS Code

Uncategorized

Nov 13 2023

Backend API

Requirements:

  • Node.js
  • npm
  • Express https://expressjs.com/en/starter/installing.html
  • mongoose
  • Nodemon
  • Studio 3T https://studio3t.com/
  • JWT

Layers (las capas):

  • api/router.js
  1. api/clients/clients.router.js
  2. api/clients/clients.controller.js
  3. api/clients/clients.service.js
  4. api/clients/clients.repository.js
  • api/clients/clients.model.js

req un res always stays in the controller.

return res.json // always with return, otherwise keeps executing the code that follows.

Import – Export

import { hola, adios } from './exportConst.js'; // importing functions as object.
import * as exportConst from './exportConst.js'; // importing all. * is naming the object.
import whatEverName from './exportDefault.js'; // when there is only one function. Possible changing functions name.

Controller

The best practice for controllers is to keep them free of business logic. Their single job is to get any relevant data from the req object and dispatch it to services. The returned value should be ready to be sent in a response using res.

Make sure you don’t pass any web layer objects (i.e. req, res, headers, etc) into your services. Instead, unwrap any values like URL parameters, header values, body data, etc before dispatching to the service layer.

params => obligatory

query => optional.

query received as string (true if exist)

JWT

Written by meudza · Categorized: Uncategorized

Nov 11 2023

Mongo

Table in mongo is collection.

Row = document

Column = value (attribute)

cardinal (n, n) generates additional table.

Foreign Key (FK) Primary Key (PK)

https://josejuansanchez.org/bd/unidad-03-teoria/index.html#relaciones-con-cardinalidad-11

https://openwebinars.net/blog/como-realizar-la-normalizacion-de-bases-de-datos-y-por-que/

Normalization

Todos atributos tiene que ser indivisibles. street, nr, zip

Todo los atributos tiene que ser del mismo tipo en la misma columna.

no deben existir grupos de valores repetidos.

T3

db = db.getSiblingDB(“vet”);

db.getCollection(“animals”).find({},{name:true, _id:false});

animals = db.getCollection(“animals”).find({}).toArray()

clients = db.getCollection(“clients”).find({_id: animals[0].clientId})

newClients = db.getCollection(“clients”).find({}).toArray()

newClients[0]._id

newAnimals = db.getCollection(“animals”).find({clientId: newClients[0]._id})

newerClients = db.getCollection(“clients”).find({fName: “Janis”}).toArray()

newerAnimals = db.getCollection(“animals”).find({clientId: newerClients[0]._id})

newerClients = db.getCollection(“clients”).find({“document.number”:“555654LV”}).toArray() //

newerAnimals = db.getCollection(“animals”).find({“clientId”: newerClients[0]._id})

newerClients = db.getCollection(“clients”).find({“document.number”:/555/}).toArray() // parcial text search

newerAnimals = db.getCollection(“animals”).find({“clientId”: newerClients[0]._id})

Written by meudza · Categorized: Uncategorized

Nov 11 2023

Backend

Server

npm

node_modules

express

Layers

Router => Route definition

Controller =>

Service => services logic

Repository => calls to DB

Written by meudza · Categorized: Uncategorized

Jul 21 2023

Falafel

Written by meudza · Categorized: Recepte, Uncategorized · Tagged: Air Fryer

Mar 24 2023

Translate

Tumeric cúrcuma kurkuma

celery apio selerija

beet remolacha

Written by meudza · Categorized: Uncategorized

  • Page 1
  • Page 2
  • Go to Next Page »

Copyright © 2026 · Altitude Pro on Genesis Framework · WordPress · Log in