import mongoose from 'mongoose' ; import Playlist from '~/models/Playlist' ; import User from '~/models/User' ; export const changeColor = async ( id , color ) => { await User . updateOne ( { id } , { color } ) ; } ; export const getMyPlaylist = async ( _id ) => { const idList = JSON . parse ( _id ) ; const play = await Playlist . find ( { _id : idList } ) ; return play ; } ; export const postMyPlaylist = async ( userId , playlistId ) => { await User . findOneAndUpdate ( { id : userId } , { $push : { myPlaylist : playlistId } } ) ; } ; export const insertLikes = async ( id , playlistId ) => { await User . updateOne ( { id } , { $addToSet : { likes : playlistId } } ) ; } ; export const deleteLikes = async ( id , _id ) => { await User . updateOne ( { id } , { $pull : { likes : _id } } , { new : true } ) ; } ;