Skip to content

Instantly share code, notes, and snippets.

@stalniy
Last active July 28, 2017 09:41
Show Gist options
  • Save stalniy/f70a8f0aac905ae8281b3c34477f769a to your computer and use it in GitHub Desktop.
Save stalniy/f70a8f0aac905ae8281b3c34477f769a to your computer and use it in GitHub Desktop.
Blog app feathers
module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
const { Schema } = mongooseClient;
const Comment = new Schema({
author: { type: Schema.Types.ObjectId, ref: 'users', required: true },
post: { type: Schema.Types.ObjectId, ref: 'posts', required: true },
text: { type: String, required: true },
}, {
timestamps: true
});
return mongooseClient.model('comments', Comment);
};
module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
const { Schema } = mongooseClient;
const Post = new Schema({
author: { type: Schema.Types.ObjectId, ref: 'users', required: true },
title: { type: String, required: true },
text: { type: String, required: true }
}, {
timestamps: true
});
return mongooseClient.model('posts', Post);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment