-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove database folder of gitignore
- Loading branch information
Showing
16 changed files
with
152 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import mongoose, { Collection } from 'mongoose' | ||
|
||
export class MongoService { | ||
client: mongoose.Mongoose | ||
|
||
async connect(uri: string): Promise<void> { | ||
this.client = await mongoose.connect(uri, {}) | ||
} | ||
|
||
async disconnect(): Promise<void> { | ||
await this.client.disconnect() | ||
} | ||
|
||
async isConnected() { | ||
const state = this.client.connection.readyState | ||
return state === 1 | ||
} | ||
|
||
getCollection(name: string): Collection { | ||
return this.client.connection.collection(name) | ||
} | ||
|
||
dropCollection(name: string): Promise<void> { | ||
return this.client.connection.dropCollection(name) | ||
} | ||
} | ||
|
||
export const mongoService = new MongoService() |
17 changes: 17 additions & 0 deletions
17
src/modules/core/database/nosql/protocols/no-sql-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export interface NoSqlService { | ||
connect(): Promise<void> | ||
disconnect(): Promise<void> | ||
isConnected(): Promise<boolean> | ||
getCollection(name: string): Promise<Collection> | ||
} | ||
|
||
export interface Collection { | ||
insertOne(data: any): Promise<any> | ||
insertMany(data: any[]): Promise<any> | ||
findOne(data: any): Promise<any> | ||
findMany(data: any): Promise<any> | ||
updateOne(data: any): Promise<any> | ||
updateMany(data: any): Promise<any> | ||
deleteOne(data: any): Promise<any> | ||
deleteMany(data: any): Promise<any> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import mongoose, { Schema } from 'mongoose' | ||
|
||
const beerSchema = new Schema({ | ||
id: { | ||
type: String, | ||
unique: true, | ||
required: true, | ||
}, | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
description: { | ||
type: String, | ||
required: true, | ||
}, | ||
imageUrl: { | ||
type: String, | ||
required: true, | ||
}, | ||
price: { | ||
type: Number, | ||
required: true, | ||
}, | ||
abv: { | ||
type: Number, | ||
required: true, | ||
}, | ||
ibu: { | ||
type: Number, | ||
required: true, | ||
}, | ||
ebc: { | ||
type: Number, | ||
required: true, | ||
}, | ||
category: { | ||
type: { | ||
id: { | ||
type: String, | ||
required: true, | ||
}, | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
createdAt: { | ||
type: Date, | ||
required: true, | ||
}, | ||
updatedAt: { | ||
type: Date, | ||
required: true, | ||
}, | ||
}, | ||
required: true, | ||
}, | ||
foodPairing: { | ||
type: [String], | ||
required: true, | ||
}, | ||
brewersTips: { | ||
type: String, | ||
required: true, | ||
}, | ||
createdAt: { | ||
type: Date, | ||
required: true, | ||
}, | ||
updatedAt: { | ||
type: Date, | ||
required: true, | ||
}, | ||
}) | ||
|
||
export const BeerModel = mongoose.model('Beer', beerSchema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
|
||
export const prismaClient = new PrismaClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters