I am setting up a website that will have users. Users can search for songs and (if signed in) save them to a playlist or their library of songs.
I want it to be like iTunes in that all the songs on the the playlists are part of the library so when the user choses to view their library of songs, the songs on the playlists are shown as well as the songs just added to the library. I'd like a song to be able to be stored in multiple playlists.
Right now I am using Mongodb, doing something like such:
var UserSchema = new Schema();
var Library = new Schema({
songs: [SongsSchema],
user: Schema.ObjectId
});
var Playlist = new Schema({
title: String,
description: String,
user: Schema.ObjectId
});
var SongsSchema = new Schema({
position: Number,
name: String,
artist: String,
artistGid: String,
album: String,
albumGid: String
time: Number,
url: String,
gid: String,
location: String (either youtube, vimeo, soundcloud for now),
playlist: [Schema.ObjectId] (array of object ids that point to playlists?)
});
Any other ideas?
edit: More details:
So what I have is a user, library, playlist, and song model.
Essentially I am trying to model something like iTunes.
A user has a library and the library belongs to that user. A user can have several playlists and the playlist belongs to the user. A song can be in many different user libraries and many different playlists that belong to different users or the same user (perhaps even on the same playlist multiple times?).
When a user visits a page they can add songs to a playlist and will also see a list of their current playlists and their library. If they click the playlist it will show all the songs on that playlist if they click library it will show all the songs in their library( so like iTunes all the songs on all the playlists and ones just added to the library).
Not sure of the best way to model this.
