Skip to content

Instantly share code, notes, and snippets.

@Lily-La-Day
Last active September 3, 2019 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lily-La-Day/b42c76996dad7b4e3378b65a0ec07d61 to your computer and use it in GitHub Desktop.
Save Lily-La-Day/b42c76996dad7b4e3378b65a0ec07d61 to your computer and use it in GitHub Desktop.

Things I Should Know

Waffly introduction (feel free to skip if you [very fairly] don't care about the backstory to this app)

Having focussed primarily on re-aquainting myself with good old Vanilla JavaScript over the last few weeks (since finishing bootcamp where I had been using a lot of React) I had started to get a few back-end cravings. To a certain extent I satisfied these by creating this full-stack portfolio thing, upon which I am (totally pointlessly) storing all of my code projects as database entries. I had decided to use a MERN stack for this though as I had used Python/Flask more recently and felt that a reminder of good old Mongo/Mongoose was in order, I also didn't need to worry about complicated relationships at all so no-SQL made sense. Now however I am having those "want to use again" feelings about Python so I have decided to make another (totally unneccassary) database, this time focussing on the very specific genre of stuff: "Things I Should Know".

This is basically allowing me to multi-task. I am getting some practical experience of database creation, and will eventually be adding a front-end - the more full-stack API building the better right? But I am also learning as I go, the idea is that every database entry will quite literally be a "thing I should know", specifically a computer science/ code thing.

Technologies used (so far)

postgreSQL|SQLAlchemy |Python|Webpack|Pip|Flask|Insomnia|TablePlus

The Code

I will start out with two models, very technically and professionally named "Code Things" and "Computer Science Things".

My codeThing model looks like this:

 
  class CodeThing(db.Model, BaseModel):

    __tablename__ = 'code_things'

    type = db.Column(db.String(120), nullable=False)
    name = db.Column(db.String(120))
    language = db.Column(db.String(50))
    example = db.Column(db.String(120))
    explanation = db.Column(db.Text)
    link = db.Column(db.String(120),)

class CodeThingsSchema(ma.ModelSchema, BaseSchema):

    class Meta:
        model = CodeThing
        

I orginally toyed with the idea of directly adding code into my database (in the eample field) as text but quickly realised this was very silly and that it is much much easier to use gists and simply link to them.

And the seeds as viewed via Insomnia in my database so far:

This is obviously a work in progress and I will be updating again soon.

On a side note - I am very happy to feel like I finally have a good understanding of what functional programming is and why it might be a preferable "way to do things". I am quite keen to try and to make something in pure vanilla JS completely functionally (if that's how you put it). Think it might be time to return to good old Rock, Paper Scissors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment