Skip to content

Link function data calls together simply and easily

Notifications You must be signed in to change notification settings

kyelewis/linked

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linkedjs

A simple library for linking data queries together and managing connections and context

Example

import { Linked } from "linkedjs";

const linked = new Linked();

linked.add({
  queries: {
    crew: () => [
      { name: "Pete", locationId: "3" },
      { name: "Steve", locationId: "7" },
    ],
    location: ({ id }) => {
      switch (id) {
        case "3":
          return { name: "Victoria" };
        case "7":
          return { name: "New South Wales" };
      }
    },
  },
  links: {
    "crew.location": (crew, linked) =>
      linked.call("location", { id: crew.locationId }),
  },
});

const result = await linked.call("crew");

// result = [ { name: "Pete", location: Function(Promise({ name: "Victoria "})) }, ... ];

About

Link function data calls together simply and easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published