0.0.1-alpha.8 • Published 2 years ago

mongorpc-node v0.0.1-alpha.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

mongorpc-node

MongoRPC Node Client

const mongorpc = require("mongorpc-node");
const grpc = require("@grpc/grpc-js");

function main() {
  const client = new mongorpc.MongoRPC(
    "localhost:1203",
    grpc.credentials.createInsecure()
  );
  const collection = client.database("sample_mflix").collection("users");

  collection
    .documents()
    .limit(1)
    .where({
      field: "name",
      equalTo: "Ned Stark",
    })
    .sort({
      field: "name",
      order: mongorpc.SortOrder.ASCENDING,
    })
    .get()
    .then((res) => {
      console.log(res);
    })
    .catch((err) => {
      console.log(err);
    })
    .finally(() => {
      console.log("finally");
    });
}

main();