Skip to content

Instantly share code, notes, and snippets.

View tarlepp's full-sized avatar
💭
örrr

Tarmo Leppänen tarlepp

💭
örrr
  • Pinja
  • Jyväskylä, Finland
View GitHub Profile
@tarlepp
tarlepp / gist:8984046
Last active August 29, 2015 13:56 — forked from jdcauley/gist:8984009
module.exports = {
index: function (req,res) {
File.find().exec(function(err, files) {
res.view({
files: files,
user: req.user
});
});
},
find: function(req, res) {
Items
.find()
.exec(function(err, val) {
if (err) {
res.send(err);
} else if (val) {
res.send(val);
} else {
res.send({});
'use strict';
/**
* @ngdoc function
* @name angApp.controller:AboutCtrl
* @description
* # AboutCtrl
* Controller of the angApp
*/
angular.module('angApp')
// Folder.js has folders object and files object
// Here we need to load a Folder's files and update some permission, until there is no folder anymore
function shareFolderRecursively(folderId, permission, next) {
var processFiles = function(files, next) {
async.each(
files,
function(file, callback) {
file.permission = permission;
file.save(callback)
},
// Folder.js has folders object and files object
// Here we need to load a Folder's files and update some permission, until there is no folder anymore
function shareFolderRecursively(folderId, permission, next) {
var processFiles = function(files, next) {
async.each(
files,
function(file, callback) {
file.permission = permission;
file.save(callback)
},
/** Context: We are going to create a sharebox system (an User has files & folder objects and can share it to his Team **/
// We have 4 models: File.js, User.js , Folder.js and Team.js
// 1) We first get the Team and we load the users in it
// 2) For each user, we need to add the association (User -> File and User->Folder)
// Loading the Team object
Team
.findOne(1)
.populate('users')
// User Model
attributes: {
username: {
type: 'string',
required: true,
unique: true,
},
sender: {
model: conversation
// User Model
attributes: {
username: {
type: 'string',
required: true,
unique: true,
},
conversationsRecipient: {
collection: 'conversation',
passport.serializeUser(function (user, next) {
next(null, user.id);
});
passport.deserializeUser(function (id, next) {
sails.models.user.findOne(id)
.populate('products')
.exec(next);
});
/**
* UserProductsController
*
* @description :: Server-side logic for managing Userproducts
* @help :: See http://sailsjs.org/#!/documentation/concepts/Controllers
*/
module.exports = {
yourAction: function(req, res) {
sails.models.product.find().sort('heat ASC').exec(function (err, products){