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 id extraction in id #257

Merged
merged 2 commits into from
Jul 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,17 @@ class Service extends AdapterService {
return this.db(params)
.insert(data, returning)
.then(rows => {
const id = data[this.id] !== undefined ? data[this.id] : rows[0];
let id

if (data[this.id] !== undefined) {
id = data[this.id]
} else if (!returning.length) {
id = rows[0]
} else if (rows[0] && rows[0][this.id]) {
id = rows[0][this.id]
}

if (!id) return rows
Copy link
Contributor Author

@KidkArolis KidkArolis Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure about this line.


return this._get(id, params);
})
Expand Down