Skip to content
Snippets Groups Projects
Commit 338147f9 authored by Matt Kirby's avatar Matt Kirby
Browse files

Added Datastore Generic

parent dec50e82
No related branches found
No related tags found
1 merge request!15Add Friend service
import mongoose, { Model, Schema } from 'mongoose'
/**
* Defines common datastore functionality
*/
export abstract class DataStore<T> {
/**
* Mongoose model pertaining to the datastore type
*/
public Model: Model<any>
constructor (modelName: string, schema: Schema) {
this.Model = mongoose.model(modelName, schema)
}
/**
* Finds a single item matching a given query
* @param query
* @returns
*/
public GetItem = async (query: any): Promise<T | null> => {
return await this.Model.findOne(query)
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment