2015-08-18 11:40:48 +00:00
|
|
|
"use strict";
|
|
|
|
|
2020-07-21 18:30:01 +00:00
|
|
|
const User = require("../user/user");
|
2015-08-18 11:40:48 +00:00
|
|
|
|
2020-07-21 18:30:01 +00:00
|
|
|
const getRandomUser = callback => {
|
|
|
|
const id = Math.floor(Math.random() * 5000) + 1;
|
|
|
|
User.find(id, function (error, user) {
|
|
|
|
if (error) return getRandomUser(callback);
|
|
|
|
return callback(error, user);
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
const getFixedUser = (id, callback) => {
|
2015-08-28 14:00:14 +00:00
|
|
|
User.find(id, function (error, user) {
|
|
|
|
if (error) return getRandomUser(callback);
|
|
|
|
return callback(error, user);
|
|
|
|
})
|
2015-08-18 11:40:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
2020-07-21 18:30:01 +00:00
|
|
|
getRandomUser,
|
|
|
|
getFixedUser
|
2015-08-18 11:40:48 +00:00
|
|
|
};
|
2019-06-10 06:55:46 +00:00
|
|
|
|
|
|
|
|