Commit 0aea4ffd authored by Sean's avatar Sean 🎨

Fix compiler errors from schema

parent 62175ea2
Pipeline #116234606 passed with stage
in 1 minute and 6 seconds
......@@ -22,10 +22,12 @@ let private handleAdd() =
| "cat" ->
printf " > What's the kitty's name? > "
let name = getInput()
printf " > How old is the kitty's name? > "
let age = getInput() |> int
printf " > What's the kitty's breed? > "
let breed = getInput()
let newCat = mkCat name breed |> insertCat
let newCat = mkCat name age breed |> insertCat
catToStr newCat |> printfn " > There's a new cat on the block: %s"
| "b"
......
......@@ -49,7 +49,7 @@ let private OwnerCats = catDb.OwnerCats
// creating entity functions - basic building blocks for CRUD functions
let private createBreed = Breeds.``Create(name)``
let private createAttribute = Attributes.``Create(description, name)``
let private createCat = Cats.``Create(breedid, name)``
let private createCat = Cats.``Create(age, breedid, name)``
let private createOwner = Owners.``Create(age, name)``
let private createBreedAttr = BreedAttrs.``Create(attributeid, breedid)``
let private createOwnerCat = Owners.``Create(age, name)``
......@@ -79,7 +79,7 @@ let private defInsertBreed: string -> unit -> int = thunkOne insertBreed
let insertCat cat =
let breedId = findBreedIdByName cat.breed.name |> Option.defaultWith (defInsertBreed cat.breed.name)
let catEntity = createCat (breedId, cat.name)
let catEntity = createCat (cat.age, breedId, cat.name)
printfn " > Makin' kitteh %s" cat.name
ctx.SubmitUpdates()
printfn " > ✅"
......
......@@ -10,11 +10,13 @@ type Breed =
type Cat =
{ id: int option
name: string
age: int
breed: Breed }
/// Make a cat with just a name and breed name, with None for ids
let mkCat catName breedName =
let mkCat catName age breedName =
{ id = None
age = age
name = catName
breed =
{ id = None
......
......@@ -7,6 +7,9 @@ module Helpers
/// Take a function, and a tuple, and call the function with the destructured tuple
let withTuple f (a, b) = f a b
/// Take a func, and a triple, and call the func with the destructured tuple
let withTriple f (a, b, c) = f a b c
/// Take anything, and give back a zero - a success exit code
let returnZero _ = 0
......
......@@ -10,17 +10,17 @@ module DB = DbAccess
/// Take a tuple and make a cat in the db, then turn it into a string
let private tupleToCatStr =
withTuple mkCat
withTriple mkCat
>> DB.insertCat
>> catToStr
let private rawCatData =
[ ("Denton", "Gray Tabby")
("Mitzie", "Tuxedo")
("Saphire", "Blue Russian")
("Ailee", "Siamese")
("Oreo", "Tuxedo")
("Frisky", "Tuxedo") ]
[ ("Denton", 2, "Gray Tabby")
("Mitzie", 6, "Tuxedo")
("Saphire", 1, "Blue Russian")
("Ailee", 2, "Siamese")
("Oreo", 6, "Tuxedo")
("Frisky", 15, "Tuxedo") ]
/// Loads a set of data into the db
let load() =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment