Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join-like methods #18

Open
Dam-Buty opened this issue May 13, 2023 · 0 comments
Open

Join-like methods #18

Dam-Buty opened this issue May 13, 2023 · 0 comments

Comments

@Dam-Buty
Copy link
Collaborator

The use case is to be able to "join" the rows from a CSV to the rows from another array of objects, using a column of each collection to determine identity.

For example :

const enrichedRows = await withCSV("").columns(["id"]).leftJoin(arrayOfObjects, { on: { left: "id", right: "uid" } })

// Alternative with a callback
const enrichedRows = await withCSV("").columns(["id"]).leftJoinBy(arrayOfObjects, (row, arrayOfObjects) => {
  return arrayOfObjects.find(object => object.uid === row.id)
})

// Also innerJoin and rightJoin variants

====

Another use case is to be able to map the value of a column to a line from a correspondance table :

const categoryNames = {
  FSN: "Fashion",
  SPT: "Sport",
  RCK: "Rock'n'roll baby"
}

const enrichedRows = await withCSV("").columns(["id", "name", "categoryId"]).mapKey("categoryId", categoryNames)

// Also mapKeyBy variant that takes a callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant