Skip to content

Instantly share code, notes, and snippets.

@soarez
soarez / model.js
Last active August 29, 2015 14:00 — forked from tdantas/model.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var Schema = mongoose.Schema;
var PageSchema = Schema({
title: { type: String, default: '', trim: true },
url: { type: String, default: '', trim: true },
thumbnails: {type: Schema.ObjectId, ref: 'Thumbnail'},
});
@soarez
soarez / answer.js
Created October 28, 2012 20:14 — forked from tdantas/question.js
programming async trick.
//Question:
// Environment: NodeJS
// Lets suppose that you have a collection of items, and your function must persist all items using the
//database.insert(item, callback ) function. When you finish the task, you should call the callback function.
// If one item raise a error, the callback(err) must be called and never call the callback anymore.
function noop() {}