8000 docs: update README.md · Tony133/nestjs-postgres@dab552a · GitHub
[go: up one dir, main page]

Skip to content

Commit dab552a

Browse files
authored
docs: update README.md
1 parent df122b6 commit dab552a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ import { InjectClient } from 'nest-postgres';
109109
export class UsersService {
110110
constructor(@InjectClient() private readonly pg: Client) {}
111111

112-
public async findAll(): Promise<any> {
112+
public async findAll(): Promise<User[]> {
113113
const users = await this.pg.query('SELECT * FROM users');
114114
return users.rows;
115115
}
@@ -127,7 +127,7 @@ export class UsersController {
127127
constructor(private readonly usersService: UsersService) {}
128128

129129
@Get()
130-
async getAllUsers() {
130+
async getAllUsers(): Promise<User[]> {
131131
return await this.usersService.findAll();
132132
}
133133
}
@@ -171,6 +171,7 @@ PostService:
171171
import { Client } from 'pg';
172172
import { InjectConnection } from 'nest-postgres';
173173
import { CreatePostDto } from './dto/create-post.dto';
174+
import { Post } from './interfaces/post.interface';
174175

175176
@Injectable()
176177
export class PostService {
@@ -179,12 +180,12 @@ export class PostService {
179180
private dbConnection: Client,
180181
) {}
181182

182-
public async findAll(): Promise<any> {
183+
public async findAll(): Promise<User[]> {
183184
const users = await this.dbConnection.query('SELECT * FROM posts');
184185
return users.rows;
185186
}
186187

187-
public async create(createPostDto: CreatePostDto): Promise<any> {
188+
public async create(createPostDto: CreatePostDto): Promise<User> {
188189
try {
189190
const user = await this.dbConnection.query(
190191
'INSERT INTO posts (title, description) VALUES ($1, $2) RETURNING *',
@@ -204,6 +205,7 @@ UsersService:
204205
import { Client } from 'pg';
205206
import { InjectConnection } from 'nest-postgres';
206207
import { CreateUserDto } from './dto/create-user.dto';
208+
import { User } from './interfaces/user.interface';
207209

208210
@Injectable()
209211
export class UsersService {
@@ -212,12 +214,12 @@ export class UsersService {
212214
private dbConnection: Client,
213215
) {}
214216

215-
public async findAll(): Promise<any> {
217+
public async findAll(): Promise<User[]> {
216218
const users = await this.dbConnection.query('SELECT * FROM users');
217219
return users.rows;
218220
}
219221

220-
public async create(createUserDto: CreateUserDto): Promise<any> {
222+
public async create(createUserDto: CreateUserDto): Promise<User> {
221223
try {
222224
const user = await this.dbConnection.query(
223225
'INSERT INTO users (firstName, lastName) VALUES ($1, $2) RETURNING *',

0 commit comments

Comments
 (0)
0