base con autenticacion, registro, modulo encuestas
This commit is contained in:
44
apps/api/src/features/location/location.service.ts
Normal file
44
apps/api/src/features/location/location.service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { DRIZZLE_PROVIDER } from 'src/database/drizzle-provider';
|
||||
// import { Env, validateString } from '@/common/utils';
|
||||
import { Inject, Injectable, HttpException, HttpStatus, NotFoundException, UnauthorizedException } from '@nestjs/common';
|
||||
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||
import * as schema from 'src/database/index';
|
||||
import { states, municipalities, parishes } from 'src/database/index';
|
||||
import { eq, like, or, SQL, sql, and, not } from 'drizzle-orm';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { State, Municipality, Parish } from './entities/user.entity';
|
||||
// import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService {
|
||||
constructor(
|
||||
@Inject(DRIZZLE_PROVIDER) private drizzle: NodePgDatabase<typeof schema>,
|
||||
) { }
|
||||
|
||||
async StateAll(): Promise< State[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(states)
|
||||
|
||||
return find;
|
||||
}
|
||||
|
||||
async MunicioalityAll(id: string): Promise< Municipality[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(municipalities)
|
||||
.where(eq(municipalities.stateId, parseInt(id)));
|
||||
|
||||
return find;
|
||||
}
|
||||
|
||||
async ParishAll(id: string): Promise< Parish[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(parishes)
|
||||
.where(eq(parishes.municipalityId, parseInt(id)));
|
||||
|
||||
return find;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user