pire
v0.4.0
Published
Pipe Request - make your request like a pipeline.
Downloads
4
Maintainers
Readme
pire
Pipe Request - make your request like a pipeline.
Example
You can write the template string in
pir
file.
If you don't want a input, use void
.
import { parsep } from 'pire'
const pir = parsep(`
void -> riot.league {
summonerName
leaguePoints
rank
wins
losses
} -> summonerId
summonerId -> riot.summoner {
profileIconId
summonerLevel
extra {
matchIds
}
} -> extra.playerId
ID -> leaguepedia.player {
ID
Team
Role
}
`)
It will be parsed as:
[
{
collectionPath: [ 'riot', 'league' ],
projection: { summonerName: 1, leaguePoints: 1, rank: 1, wins: 1, losses: 1 },
outputFieldPath: [ 'summonerId' ]
},
{
inputFieldPath: [ 'summonerId' ],
collectionPath: [ 'riot', 'summoner' ],
projection: { profileIconId: 1, summonerLevel: 1, extra: { matchIds: 1 } },
outputFieldPath: [ 'extra', 'playerId' ]
},
{
inputFieldPath: [ 'ID' ],
collectionPath: [ 'leaguepedia', 'player' ],
projection: { ID: 1, Team: 1, Role: 1 }
}
]