Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create returns undefined if data is empty array (for multi) #394

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

bwgjoseph
Copy link
Contributor

@bwgjoseph bwgjoseph commented Oct 3, 2020

Currently, if the service is defined as multi = ['create'] and pass in empty array to service.create, it will throw TypeError: Cannot read property 'map' of undefined

Hence, this fix adds check to return empty array if the result is undefined so it exits early, and does not throw error

Also, because the test runs on @feathersjs/adapter-tests, I can add an updated test case to .create multi if required

const emptyData = await service.create([]);

assert.ok(Array.isArray(emptyData));
assert.ok(emptyData.length === 0);

If this does gets accepted, do consider adding topic and label for hacktoberfest so it counts towards the contribution

@daffl daffl merged commit 5a0aa88 into feathersjs-ecosystem:master Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants