base de datos casi completa
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user