Skip to content

Instantly share code, notes, and snippets.

@TonyPythoneer
TonyPythoneer / timestamp.js
Created February 13, 2016 16:03
mongoose 自动生成数据的创建时间和跟新时间
/**
* Timestamps 用于自动产生数据的创建时间和更新时间
*
* 使用方法:
*
* schema.plugin(require('./timestamp'));
*
*/
var timestampsPlugin = function (schema) {
if (schema.path('_id')) {
@TonyPythoneer
TonyPythoneer / api.js
Created February 11, 2016 01:20 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');