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
// User Model
attributes: {
username: {
type: 'string',
required: true,
unique: true,
},
conversationsRecipient: {
collection: 'conversation',
// User Model
attributes: {
username: {
type: 'string',
required: true,
unique: true,
},
sender: {
model: conversation
/** 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')
// 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)
},
'use strict';
/**
* @ngdoc function
* @name angApp.controller:AboutCtrl
* @description
* # AboutCtrl
* Controller of the angApp
*/
angular.module('angApp')
find: function(req, res) {
Items
.find()
.exec(function(err, val) {
if (err) {
res.send(err);
} else if (val) {
res.send(val);
} else {
res.send({});
@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
});
});
},