Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 5 additions & 8 deletions adapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// deno-lint-ignore-file no-unused-vars
import { crocks, R } from "./deps.js";
import { formatDocs, queryOptions, xId } from "./utils.js";
import { formatDocs, queryOptions } from "./utils.js";

const { Async, tryCatch, resultToAsync } = crocks;
const {
Expand All @@ -15,8 +15,6 @@ const {
pluck,
set,
split,
over,
identity,
} = R;
const cmd = (n) => (db) => Async.fromPromise(db[n].bind(db));

Expand Down Expand Up @@ -145,8 +143,8 @@ export function adapter(client) {
)
.chain((db) =>
insertOne(db)({
_id: id,
...doc,
_id: id,
})
.bimap(
(e) => ({ ok: false, status: 409, id, msg: e.message }),
Expand Down Expand Up @@ -174,7 +172,6 @@ export function adapter(client) {
? Async.Resolved(doc)
: Async.Rejected({ ok: false, status: 404, msg: "Not Found!" })
)
.map(over(xId, identity))
.toPromise();
}

Expand Down Expand Up @@ -232,7 +229,7 @@ export function adapter(client) {
...queryOptions(query),
noCursorTimeout: undefined,
}).toArray();
return { ok: true, docs: map(over(xId, identity), docs) };
return { ok: true, docs };
} catch (e) {
console.log(e);
return { ok: false, msg: e.message };
Expand Down Expand Up @@ -297,7 +294,7 @@ export function adapter(client) {
noCursorTimeout: undefined,
}).toArray();

return { ok: true, docs: map(over(xId, identity), docs) };
return { ok: true, docs };
} catch (e) {
console.log("ERROR: ", e.message);
return { ok: false, msg: e.message };
Expand Down Expand Up @@ -333,7 +330,7 @@ export function adapter(client) {
(_) => ({
ok: true,
results: map(
(d) => ({ ok: true, id: d.id || d._id, _id: d._id }),
(d) => ({ ok: true, id: d._id }),
docs,
),
}),
Expand Down
8 changes: 1 addition & 7 deletions adapter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ test("get document", async () => {
});
assertEquals(doc.title, "Groundhog Day");
assertEquals(doc._id, "3-groundhog-day");
// TODO: remove when blueberry is released
assertEquals(doc.id, doc._id);
// cleanup
await a.removeDocument({ db: "hyper~movies", id: "3-groundhog-day" });
await a.removeDocument({ db: "hyper~movies", _id: "3-groundhog-day" });
});

test("update document", async () => {
Expand Down Expand Up @@ -121,8 +119,6 @@ test("query documents", async () => {

assert(result.ok);
assertEquals(result.docs[0]._id, "15-starwars");
// TODO: remove when blueberry is released
assertEquals(result.docs[0].id, result.docs[0]._id);

// cleanup
await a.removeDocument({ db: "hyper~movies", id: "10-caddyshack" });
Expand Down Expand Up @@ -156,8 +152,6 @@ test("list documents", async () => {
assert(result.ok);
assertEquals(result.docs.length, 2);
assertEquals(result.docs[0]._id, "20-caddyshack");
// TODO: remove when blueberry is released
assertEquals(result.docs[0].id, result.docs[0]._id);

// cleanup
await a.removeDocument({ db: "hyper~movies", id: "20-caddyshack" });
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
deno test --no-check --allow-net --allow-env --import-map=https://x.nest.land/hyper-test@0.0.4/import_map.json https://x.nest.land/hyper-test@0.0.4/mod.js
deno test --allow-net --allow-env --no-check --import-map=https://x.nest.land/hyper-test@2.0.0/import_map.json https://x.nest.land/hyper-test@2.0.0/mod.js
2 changes: 1 addition & 1 deletion test/hyper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Harness deps
import { default as appOpine } from "https://x.nest.land/hyper-app-opine@1.2.7/mod.js";
import { default as core } from "https://x.nest.land/hyper@1.5.2/mod.js";
import { default as core } from "https://x.nest.land/hyper@2.0.0/mod.js";

import mongo from "../mod.js";
import PORT_NAME from "../port_name.js";
Expand Down
9 changes: 1 addition & 8 deletions utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { R } from "./deps.js";

const { assoc, map, omit, keys, values, lens, prop } = R;

export const xId = lens(prop("_id"), assoc("id"));
const { assoc, map, omit, keys, values } = R;

export const formatDocs = map((d) => {
d = omit(["id"], {
...d,
_id: d._id || d.id,
});

if (d._deleted) {
return { deleteOne: { filter: { _id: d._id } } };
} else if (d._update) {
Expand Down