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

Store deleted documents in the kdb index. #43

Closed
wants to merge 2 commits into from

Conversation

hackergrrl
Copy link
Contributor

This is a prerequisite for the larger goal of exposing deletions through the osm-p2p-db API.

index.js Outdated
@@ -43,7 +43,8 @@ function DB (opts) {
if (v && v.lat !== undefined && v.lon !== undefined) {
next(null, { type: 'put', point: ptf(v) })
} else if (d && Array.isArray(row.value.points)) {
next(null, { type: 'del', points: row.value.points.map(ptf) })
var pt = row.value.points.map(ptf)[0]
Copy link
Member

Choose a reason for hiding this comment

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

We need an index record for each point in row.value.points. This property is set in the delete code and is an array of the lat/lon of each parent. Each of those records should be updated to point to the deleted record, i.e. we need two puts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are 100% right; good catch.

index.js Outdated
} else if (doc && doc.value && doc.value.d && doc.value.points) {
var pt = doc.value.points[0]
pt.deleted = true
addDoc(doc.value.d, link, pt)
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand what this block is doing, can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm marking deleted documents as such, but (below) filtering them out. This means no API changes or change in behaviour, but the new logic is in place. This is to make the breaking change PR smaller and a bit easier to reason about.

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.

2 participants