Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Add Operation Hooks to a LoopBack model

    loopbackLoopback
    ^3.0.0

    In this lesson we will learn how to add operation hooks to our models. In the Product model we will create a before safe observer that will check if the category we want to add the product to exists.

    In our Category model we will create a before delete observer to prevent categories from being deleted when they have products.

    We will create a unit test to verify that both of these operation hooks work as expected.