This file contains hidden or 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
/////////////////////////////////////////////////////// | |
// $ node unique-json-parser.js [file_you_want_to_parse] | |
/////////////////////////////////////////////////////// | |
var fs = require('fs'); | |
var file_name = process.argv[2]; | |
var obj = {} | |
fs.readFile(file_name + '.json', { encoding: 'utf8' }, function(err, obj) { |
This file contains hidden or 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
/////////////////////////////////////////////////////// | |
// $ node txt-to-json-parser.js [file_you_want_to_parse] | |
/////////////////////////////////////////////////////// | |
var fs = require('fs'); | |
var arr = [] | |
var file_name = process.argv[2]; | |
var stream = fs.createReadStream(file_name + '.txt', { flags: 'r+', encoding: 'utf-8' }); | |
var buf = ''; |
This file contains hidden or 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
/* fetch all users user_totaldocs and user_totalthings values and want to sum those variables.*/ | |
var userSchema = mongoose.Schema({ | |
local : { | |
... | |
... | |
user_id : String, | |
user_totaldocs : Number, | |
user_totalthings : Number | |
.... |
This file contains hidden or 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 all companies that people with lastname "Robertson" have founded | |
*/ | |
var mongoose = require('mongoose'); | |
var PersonSchema = new mongoose.Schema { | |
firstname: String, | |
lastname: String | |
}; | |
var Person = mongoose.model('Person', PersonSchema); |
NewerOlder