2
\$\begingroup\$

I've created the following node module to define my model. Is this a reasonable approach?

Model.js:

var dynamoose = require('dynamoose');

var product = dynamoose.model('Product', { id: Number, name: String });
var giftCard = dynamoose.model('GiftCard', { id: Number, name: String });

exports.product = product;
exports.giftCard = giftCard;

index.js:

var m = require('model');
var coffeeMug = new m.product('1111','Coffee Mug')
console.log(coffeeMug);
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You should explain in more detail that you're using Dynamoose, because its way of creating models is a bit different from the "default" Node.js way. I would also recommend to instantiate objects like this: new m.product({id: '1111', name: 'Coffee Mug'}). It increases readability and you and other developers will always know which properties are actually set. \$\endgroup\$ Commented Jan 17, 2017 at 7:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.