digidem / comapeo-core

A local-first library for collaborating on mapping projects
MIT License
8 stars 1 forks source link

fix: `DataType.prototype.getByVersionId` could return wrong type #963

Open EvanHahn opened 1 week ago

EvanHahn commented 1 week ago

We have many DataTypes backed by the same DataStore. For example, observations and tracks are both in the "data" store.

DataType.prototype.getByVersionId would pull documents from the store without checking the type, which could cause issues. Simple code example:

const track = await trackDataType.create({ /* ... */ })

await observationDataType.getByVersionId(track.versionId)
// => the track, unexpectedly!

Now, it throws a NotFoundError.