base de datos casi completa
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2020": true
|
||||
},
|
||||
"extends": [
|
||||
"standard"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 11,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
+5
-77
@@ -1,78 +1,6 @@
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
.idea/
|
||||
.vscode/
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
build/
|
||||
tmp/
|
||||
temp/
|
||||
@@ -1,12 +0,0 @@
|
||||
Copyright (C) 2006 by Rob Landley <rob@landley.net>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -1,2 +1,7 @@
|
||||
# api
|
||||
# Awesome Project Build with TypeORM
|
||||
|
||||
Steps to run this project:
|
||||
|
||||
1. Run `npm i` command
|
||||
2. Setup database settings inside `ormconfig.json` file
|
||||
3. Run `npm start` command
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"type": "mysql",
|
||||
"host": "localhost",
|
||||
"port": 3306,
|
||||
"username": "local",
|
||||
"password": "123",
|
||||
"database": "pcpuma",
|
||||
"synchronize": true,
|
||||
"logging": false,
|
||||
"entities": [
|
||||
"src/db/entity/**/*.ts"
|
||||
],
|
||||
"migrations": [
|
||||
"src/db/migration/**/*.ts"
|
||||
],
|
||||
"subscribers": [
|
||||
"src/db/subscriber/**/*.ts"
|
||||
],
|
||||
"cli": {
|
||||
"entitiesDir": "src/db/entity",
|
||||
"migrationsDir": "src/db/migration",
|
||||
"subscribersDir": "src/db/subscriber"
|
||||
}
|
||||
}
|
||||
Generated
+2345
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "0.0.1",
|
||||
"description": "Awesome project developed with TypeORM.",
|
||||
"devDependencies": {
|
||||
"@types/node": "^8.0.29",
|
||||
"@typescript-eslint/eslint-plugin": "^3.7.0",
|
||||
"@typescript-eslint/parser": "^3.7.0",
|
||||
"eslint": "^7.5.0",
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"ts-node": "3.3.0",
|
||||
"typescript": "3.3.3333"
|
||||
},
|
||||
"dependencies": {
|
||||
"typeorm": "0.2.25",
|
||||
"reflect-metadata": "^0.1.10",
|
||||
"mysql": "^2.14.1"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "ts-node src/index.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Entity, OneToMany } from 'typeorm'
|
||||
import { Catalogo } from './Catalogo'
|
||||
import { Reservacion } from './Reservacion'
|
||||
|
||||
@Entity()
|
||||
export class Actividad extends Catalogo {
|
||||
@OneToMany(
|
||||
(type) => Reservacion,
|
||||
(reservacion) => reservacion.actividad
|
||||
)
|
||||
reservaciones: Reservacion[];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Entity, ManyToOne } from 'typeorm'
|
||||
import { Catalogo } from './Catalogo'
|
||||
import { Reservacion } from './Reservacion'
|
||||
|
||||
@Entity()
|
||||
export class Adscripcion extends Catalogo {
|
||||
@ManyToOne(
|
||||
(type) => Reservacion,
|
||||
(reservacion) => reservacion.adscripcion
|
||||
)
|
||||
reservaciones: Reservacion[];
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import {
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
Entity,
|
||||
OneToOne,
|
||||
JoinColumn
|
||||
} from 'typeorm'
|
||||
import { TipoProblema } from './TipoProblema'
|
||||
|
||||
@Entity()
|
||||
export class Ayuda {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
nombre: string;
|
||||
|
||||
@Column()
|
||||
correo: string;
|
||||
|
||||
@Column()
|
||||
descripcion: string;
|
||||
|
||||
@Column()
|
||||
solucion: string;
|
||||
|
||||
@OneToOne((type) => TipoProblema)
|
||||
@JoinColumn()
|
||||
tipoProblema: TipoProblema;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
OneToMany
|
||||
} from 'typeorm'
|
||||
import { Tipo } from './Tipo'
|
||||
import { Reservacion } from './Reservacion'
|
||||
import { Equipo } from './Equipo'
|
||||
|
||||
@Entity()
|
||||
export class Carrito {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
sobrenombre: number;
|
||||
|
||||
@Column()
|
||||
kiosko: number;
|
||||
|
||||
@OneToMany(
|
||||
(type) => Reservacion,
|
||||
(reservacion) => reservacion.carrito
|
||||
)
|
||||
reservaciones: Reservacion[];
|
||||
|
||||
@OneToMany(
|
||||
(type) => Equipo,
|
||||
(equipo) => equipo.carrito
|
||||
)
|
||||
equipos: Equipo[];
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Tipo,
|
||||
(tipo) => tipo.carritos
|
||||
)
|
||||
tipo: Tipo;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
|
||||
export abstract class Catalogo {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
nombre: string;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'
|
||||
import { Carrito } from './Carrito'
|
||||
|
||||
@Entity()
|
||||
export class Equipo {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
noSerie: string;
|
||||
|
||||
@Column()
|
||||
noInventario: string;
|
||||
|
||||
@Column()
|
||||
alias: string;
|
||||
|
||||
@Column({ type: 'boolean' })
|
||||
activo: boolean;
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Carrito,
|
||||
(carrito) => carrito.equipos
|
||||
)
|
||||
carrito: Carrito;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Entity, OneToMany } from 'typeorm'
|
||||
import { Catalogo } from './Catalogo'
|
||||
import { Reservacion } from './Reservacion'
|
||||
|
||||
@Entity()
|
||||
export class Lugar extends Catalogo {
|
||||
@OneToMany(
|
||||
(type) => Reservacion,
|
||||
(reservacion) => reservacion.lugar
|
||||
)
|
||||
reservaciones: Reservacion[];
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
|
||||
@Entity()
|
||||
export class Prestamo {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
activo: boolean;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaInicio: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaFin: string;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm'
|
||||
import { Actividad } from './Actividad'
|
||||
import { Adscripcion } from './Adscripcion'
|
||||
import { Lugar } from './Lugar'
|
||||
import { Carrito } from './Carrito'
|
||||
|
||||
@Entity()
|
||||
export class Reservacion {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaInicio: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
fechaFin: string;
|
||||
|
||||
@Column()
|
||||
descripcion: string;
|
||||
|
||||
@Column({ type: 'boolean' })
|
||||
uso: boolean;
|
||||
|
||||
@Column({ type: 'boolean' })
|
||||
cancelado: boolean;
|
||||
|
||||
@Column({ type: 'boolean' })
|
||||
aceptado: boolean;
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Actividad,
|
||||
(actividad) => actividad.reservaciones
|
||||
)
|
||||
actividad: Actividad;
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Adscripcion,
|
||||
(adscripcion) => adscripcion.reservaciones
|
||||
)
|
||||
adscripcion: Adscripcion;
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Lugar,
|
||||
(lugar) => lugar.reservaciones
|
||||
)
|
||||
lugar: Lugar;
|
||||
|
||||
@ManyToOne(
|
||||
(type) => Carrito,
|
||||
(carrito) => carrito.reservaciones
|
||||
)
|
||||
carrito: Carrito;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Entity, OneToMany, Equal } from 'typeorm'
|
||||
import { Catalogo } from './Catalogo'
|
||||
import { Equipo } from './Equipo'
|
||||
import { Carrito } from './Carrito'
|
||||
|
||||
@Entity()
|
||||
export class Tipo extends Catalogo {
|
||||
@OneToMany(
|
||||
(type) => Carrito,
|
||||
(carrito) => carrito.tipo
|
||||
)
|
||||
carritos: Carrito[];
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PrimaryGeneratedColumn, Column, Entity } from 'typeorm'
|
||||
|
||||
@Entity()
|
||||
export class TipoProblema {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
nombre: string;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";
|
||||
|
||||
@Entity()
|
||||
export class User {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
firstName: string;
|
||||
|
||||
@Column()
|
||||
lastName: string;
|
||||
|
||||
@Column()
|
||||
age: number;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
|
||||
@Entity()
|
||||
export class Usuario {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: string;
|
||||
|
||||
@Column()
|
||||
nombre: string;
|
||||
|
||||
@Column()
|
||||
apellidoPaterno: string;
|
||||
|
||||
@Column()
|
||||
apellidoMaterno: string;
|
||||
|
||||
@Column()
|
||||
correoAlternativo: string;
|
||||
|
||||
@Column()
|
||||
numeroTelefonico: string;
|
||||
|
||||
@Column()
|
||||
identificacion: string;
|
||||
|
||||
@Column()
|
||||
institucion: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
multa: string;
|
||||
|
||||
@Column({ type: 'date' })
|
||||
multaRed: string;
|
||||
|
||||
@Column()
|
||||
baja: boolean;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import "reflect-metadata";
|
||||
import { createConnection } from "typeorm";
|
||||
import { User } from "./db/entity/User";
|
||||
import { TipoProblema } from "./db/entity/TipoProblema";
|
||||
import { Ayuda } from "./db/entity/Ayuda";
|
||||
|
||||
createConnection()
|
||||
.then(async (connection) => {
|
||||
console.log("Inserting a new user into the database...");
|
||||
const user = new User();
|
||||
user.firstName = "Timber";
|
||||
user.lastName = "Saw";
|
||||
user.age = 25;
|
||||
await connection.manager.save(user);
|
||||
console.log("Saved a new user with id: " + user.id);
|
||||
const tipoProblema = new TipoProblema();
|
||||
tipoProblema.nombre = "test";
|
||||
const ayuda = new Ayuda();
|
||||
ayuda.nombre = "test";
|
||||
ayuda.correo = "correo@test";
|
||||
ayuda.solucion = "sdasd";
|
||||
ayuda.descripcion = "daskdjskjdjasda";
|
||||
ayuda.tipoProblema = tipoProblema;
|
||||
|
||||
await connection.manager.save(tipoProblema);
|
||||
await connection.manager.save(ayuda);
|
||||
|
||||
console.log("Loading users from the database...");
|
||||
const users = await connection.manager.find(User);
|
||||
const problemas = await connection.manager.find(TipoProblema);
|
||||
const ayudasRep = connection.getRepository(Ayuda);
|
||||
const ayudas = await ayudasRep.find({ relations: ["tipoProblema"] });
|
||||
console.log("Loaded users: ", users);
|
||||
console.log("Loaded users: ", problemas);
|
||||
console.log("Loaded users: ", ayudas);
|
||||
|
||||
console.log("Here you can setup and run express/koa/any other framework.");
|
||||
})
|
||||
.catch((error) => console.log(error));
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"es5",
|
||||
"es6"
|
||||
],
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./build",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user