Integrate timestamps and uploaders

This commit is contained in:
Jose 2020-08-22 21:12:55 -05:00
commit 199ed6837a

View file

@ -1,19 +1,31 @@
import { Document, model, Schema } from 'mongoose' import { Document, model, Schema } from 'mongoose'
import shortid from 'shortid' import shortid from 'shortid'
import moment from 'moment'
const ImgSchema = new Schema({ const ImgSchema = new Schema({
_id: { _id: {
type: String, type: String,
default: shortid.generate default: shortid.generate
}, },
data: Buffer, createdAt: {
contentType: String type: Date,
default: moment().toISOString()
},
uploaders: [String],
img: {
contentType: String,
data: Buffer,
}
}) })
export type ImgType = Document & { export type ImgType = Document & {
_id: string, _id: string,
data: Buffer, createdAt: Date,
contentType: string uploaders: string[],
img: {
contentType: string,
data: Buffer
}
} }
export default model<ImgType>("Images", ImgSchema, "Images") export default model<ImgType>("Images", ImgSchema, "Images")