re: A crash course on Serverless with AWS - Building APIs with Lambda and Aurora Serverless VIEW POST

VIEW PARENT COMMENT VIEW FULL DISCUSSION
 

Add another model to the object.
In db.js:

const Models = { Note, User }

Once you want to require the models in the handler.js you can choose which one you want.

const { Note } = await connectToDatabase()
// or
const { User } = await connectToDatabase()
// or even
const { Note, User } = await connectToDatabase()

It's up to you to use what you like more. I personally think destructuring is freaking awesome. :)

 

Thanks so much, I'll try the above. thanks again

 

Last question, what would be the best way to associate those two tables? I've found many examples, but it would require a refactoring of the model's .js file.

code of conduct - report abuse