<commit_before>var mongoose = require('mongoose');
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/mongo-crud');
var db = mongoose.connection;

var User = require('../../models/User.js');

var done = function() {
  db.close();
};

var showUserPages = function(user_id) {
  User.findById(user_id, function(err, user){
    if (err) {
      return err;
    } 
    console.log(user);
    return user;
  })
  .exec()
  .then(function(user) {
    console.log("Found a user");
    console.log(user);
  }).catch(function(error){
    console.error(error);
  }).then(done);
};

db.once('open', function(){
  var user_id = process.argv[2];
  showUserPages(user_id);
});<commit_msg>Adds script to find pages by user<commit_after>

var mongoose = require("../../models/index");
var db = mongoose.connection;
var User = mongoose.model("User");


var done = function() {
  db.close();
};

var showUserPages = function(user_id) {
  User.findById({_id: user_id})
  .exec()
  .then(function(user) {
    console.log(user.populate('pages'));
  })
  // .then(function(user){
  //   console.log(user.pages);
  // })
  .catch(function(error){
    console.error(error);
  }).then(done);
};

db.once('open', function(){
  var user_id = process.argv[2];
  showUserPages(user_id);
});
{'fraction_non_alphanumeric': 0.19422776911076442, 'fraction_numerical': 0.0015600624024961, 'mean_word_length': 3.787313432835821, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3060895', 'n_tokens_mistral': 453, 'n_tokens_neox': 457, 'n_words': 83}