-
Notifications
You must be signed in to change notification settings - Fork 109
How to use
Pipe Dream works with the concept of a Sketch
and a Schema
.
When the word "Entity" is used in this documentation, it means either a Model, Table, PivotTable or UserModel.
The sketch has 4 rules to remember:
- Models are created by upper-casing the first letter, e.g
Car
- Tables that does not have a model should be written all lowercase, e.g
votes
- PivotTables (Many-To-Many relationships) are written with both models in lowercase with an underscore (_) between, e.g
car_garage
- A double linebreak (
\n\n
) signifies a new entity (Model, Table etc.)
You can pass different arguments into each Entity by writing a >
after the Entity name followed by a key. Each argument can have multiple values passed as well by using a colon :
between each value. Each Arguments are split by using a comma ,
.
If no value as passed to the argument its value defaults to true
.
Values are automatically cast to an appropriate type
It's important to remember that Pipe Dream in and of itself does not use passed arguments for anything. It's simply a tool to allow third party packages to "listen" for specific keywords and attributes
Examples:
Car > softdeletes // Applies softdeletes to the Car model
Car > color:Yellow // Sets the color to "Yellow"
Car > colors:Yellow:Green:Red:Pink // Set the colors to an array of [Yellow, Green, Red, Pink]
Car > softdeletes, isFast:false, someArray:1:null:false:"I am a string
/*
The above arguments solves as follows:
The Entity is a Model (first letter is uppercase)
It has softdeletes set to true
The isFast is boolean false
someArray is [1, null, false, "I am a string"]
*/
Pipe Dream can load segments that's hosted on pastebin or other sites that serves raw text. This can be very handy when you need to use the same sketch-parts over and over again (for example, saving the setup for using OAuth or a forum setup).
To use pastebins, simple write
pastebin > {pastebinID} // e.g pastebin > 8M4FbkHc to load the sample app
A button will be displayed in the upper right part of the sketch window, click this to load the pastebin directly into the sketch.
Pipe Dream will automatically merge offsite segments with your own settings:
pastebin > 8M4FbkHc // Pipe Dream sample app
Car
isFast
released_at
// When clicking the button to download the pastebin, the new Car entity will look like this:
Car
isFast
released_at
brand
color
user_id
If you do not want to use pastebin, you can use load
instead to load from any website that offers raw text output:
load > https://raw.githubusercontent.com/some-repo/some-file
Offsite segments are recursive, so you can have pastebins inside pastebins (each response are saved locally, so circular calls will be ignored).
The Schema holds a deserialized object of your sketch. This can help you to take a deeper look into how your final project will look like.