Closed critichu closed 5 years ago
Merging #69 into master will increase coverage by
6.63%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #69 +/- ##
==========================================
+ Coverage 40.61% 47.24% +6.63%
==========================================
Files 32 33 +1
Lines 426 436 +10
==========================================
+ Hits 173 206 +33
+ Misses 253 230 -23
Impacted Files | Coverage Δ | |
---|---|---|
R/doc_upsert.R | 100% <100%> (ø) |
|
R/revisions.r | 80% <0%> (+80%) |
:arrow_up: |
R/doc_get.r | 100% <0%> (+100%) |
:arrow_up: |
R/doc_update.r | 100% <0%> (+100%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update b1f0727...5ad5f86. Read the comment docs.
thanks @critichu i'll have a look
LGTM. The only thing that comes to mind: Currently doc_upsert()
doesn't support the data.frame/list inputs to doc_create()
. It's made harder in that doc_update()
doesn't support data.frame/list inputs anyway. So for now I think we leave as is, and if we add data.frame/list inputs to doc_update()
then we can add data.frame/list inputs to doc_upsert()
as well. Sound good? Any complaints?
Sounds good!
Indeed I kept the arguments symmetric for both (create and update) cases, hence the current data.frame
/list
limitation.
Is an update to doc_update()
planned in the near future perhaps?
Is an update to
doc_update()
planned in the near future perhaps?
it could be, i'll open an issue.
for now I think we move on with this, and we can add support for other classes later
Added a new function called
doc_upsert()
that updates an existing document or creates it if it doesn't yet exist.Description
doc_upsert()
first retrieves the latest revision number for a given document id (docid
) -- usingdb_revisions()
It then updates that document to the given
doc
-- usingdoc_update()
If the
docid
does not exist, then the first step will fail.This is handled in
doc_upsert()
, which reverts to creating the document -- usingdoc_create()
Example
Tests
doc_upsert()
is using existingsofa
functions.Nevertheless I included unit tests in the
tests/testthat
folder.