Skip to content

Commit

Permalink
fix(_type): ensure _type and _meta/_type match
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Jul 19, 2022
1 parent 74b70b0 commit b7efe57
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions oada/services/write-handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const metaPointers = {
* Reusable JSON Pointer to `/_meta/_rev`
*/
rev: JsonPointer.create('/_meta/_rev'),
/**
* Reusable JSON Pointer to `/_meta/_type`
*/
type: JsonPointer.create('/_meta/_type'),
/**
* Reusable JSON Pointer to `/_meta/_changes`
*/
Expand Down Expand Up @@ -339,6 +343,13 @@ async function doWrite(
object._rev = rev;
metaPointers.rev.set(object, rev, true);

/**
* ???: What should the order of precedence be?
*/
const type = object?._type || object?._meta?._type || undefined;
object._type = type;
metaPointers.type.set(object, type, true);

/**
* ???: Error is body contains a non-matching `_id`
*/
Expand Down

0 comments on commit b7efe57

Please sign in to comment.