This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
index: function (req,res) { | |
File.find().exec(function(err, files) { | |
res.view({ | |
files: files, | |
user: req.user | |
}); | |
}); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find: function(req, res) { | |
Items | |
.find() | |
.exec(function(err, val) { | |
if (err) { | |
res.send(err); | |
} else if (val) { | |
res.send(val); | |
} else { | |
res.send({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* @ngdoc function | |
* @name angApp.controller:AboutCtrl | |
* @description | |
* # AboutCtrl | |
* Controller of the angApp | |
*/ | |
angular.module('angApp') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User Model | |
attributes: { | |
username: { | |
type: 'string', | |
required: true, | |
unique: true, | |
}, | |
sender: { | |
model: conversation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User Model | |
attributes: { | |
username: { | |
type: 'string', | |
required: true, | |
unique: true, | |
}, | |
conversationsRecipient: { | |
collection: 'conversation', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport.serializeUser(function (user, next) { | |
next(null, user.id); | |
}); | |
passport.deserializeUser(function (id, next) { | |
sails.models.user.findOne(id) | |
.populate('products') | |
.exec(next); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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){ |
OlderNewer