dexie-relationships icon indicating copy to clipboard operation
dexie-relationships copied to clipboard

oneToMany with no matches should get empty array instead of undefined

Open dfahlander opened this issue 8 years ago • 0 comments

Basically, I would like to assert that when expecting an "albums" property, it should always be there. If no items matches, it should be empty instead of not defined at all:

db.bands.add({
        id: 3,
        name: 'Band without albums',
        genreId: 1
})

const results = await db.bands.with({albums: 'albums'});

// Here's the assertion I would like to have:
assert (results.every(band => band.albums && Array.isArray(band.albums)));

dfahlander avatar Mar 16 '17 10:03 dfahlander