Hi there,
First, you'll need a nice immutable data structures library (I don't know the details). Then you'll want some simple container types like this:
class ImageCollection {
constructor(
public readonly nextSeq : number,
public readonly albums : ImmutableMap<number, Album>) {}
};
class Album {
constructor(
public readonly nextSeq : number,
public readonly images : ImmutableMap<number, Image>) {}
}
nextSeq is your generator for unique indexes. To add a new item, you'd take the value of nextSeq for the key of the new item, and increment nextSeq. ... something like this:
const neu = new ImageCollection(coll.nextSeq+1,
coll.albums.insert(coll.nextSeq, newAlbum));
You could make this into a helper method on ImageCollection.
The numbers then give you unique keys you can use to refer to the albums and images, to implement delete operations, etc. I hope that's helpful!
Steve