Skip to content

Instantly share code, notes, and snippets.

@b-bot
Last active May 12, 2020 14:02
Show Gist options
  • Save b-bot/43858d50a3dbaa110355aaff89ce3ed2 to your computer and use it in GitHub Desktop.
Save b-bot/43858d50a3dbaa110355aaff89ce3ed2 to your computer and use it in GitHub Desktop.
// The `CreateCollection` is similar to `CREATE TABLE ` in SQL. The same for `CreateIndex`.
CreateCollection({name: "artists"});
CreateCollection({name : "songs"});
CreateCollection({name : "albums"});
// We are emulating the primary keys of each respective table by specifying unique as true.
CreateIndex({name : "artists_by_id", source : Collection("artists"), terms : [ {field : [ "data", "artist_id" ]} ], unique : true})
CreateIndex({name : "songs_by_id", source : Collection("songs"), terms : [ {field : [ "data", "song_id" ]} ], unique : true})
CreateIndex({name : "albums_by_id", source : Collection("albums"), terms : [ {field : [ "data", "album_id" ]} ], unique : true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment