mainimg.db.ts 752 Bytes
Newer Older
Kim, MinGyu's avatar
Kim, MinGyu committed
1
2
3
4
5
6
7
8
9
import { ObjectId } from "mongoose";
import { Avatar, IAvatar, Mainimg, MainimgType } from "../models";

export const createMainimg = async (mainimg: MainimgType, pic: IAvatar) => {
  const newPic = await Avatar.create({
    originalfilename: pic.originalfilename,
    newfilename: pic.newfilename,
    pictureauth: pic.picturepath,
  });
백승민's avatar
백승민 committed
10
11
12
13

  const newMainimg = await Mainimg.create({
    theme: mainimg.theme,
    city: mainimg.city,
Kim, MinGyu's avatar
Kim, MinGyu committed
14
    pic: newPic._id,
백승민's avatar
백승민 committed
15
16
17
18
19
20
    title: mainimg.title,
  });
  return newMainimg;
};

export const getMainimg = async () => {
Kim, MinGyu's avatar
Kim, MinGyu committed
21
22
23
24
  const img = await Mainimg.find({}).populate("pic");

  return img;
};
백승민's avatar
백승민 committed
25
26
27
28
29

export const deleteOneMainimg = async (_id: string) => {
  const res = await Mainimg.deleteOne({ _id: _id });
  return res;
};