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
// The code snippet below is functional, but is made ugly on purpose | |
// Please refactor it to a state you'd be satisfied with and send back the refactored code | |
// Bonus challenge: there is a simple change that will improve database writes drastically | |
// Can you spot it? | |
const startCronJob = require('nugttah-backend/helpers/start.cron.job'); | |
const Helpers = require('nugttah-backend/helpers'); | |
const Invoice = require('nugttah-backend/modules/invoices'); | |
const DirectOrder = require('nugttah-backend/modules/direct.orders'); | |
const Part = require('nugttah-backend/modules/parts'); |
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
import mongoose from 'mongoose'; | |
const { Schema } = mongoose; | |
const ALL_BANK_ACCOUNTS_COUNT = 100_000; | |
start().catch(console.error); | |
async function start () { | |
await runExperiment(bulkSaveDocuments); | |
await runExperiment(saveDocumentsIndividually); |
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
{ | |
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
"blocks": [ | |
{ | |
"type": "prompt", | |
"alignment": "left", | |
"segments": [ | |
{ | |
"type": "path", | |
"style": "powerline", |
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
// https://stackoverflow.com/questions/65831219/mongodb-bulkwrite-multiple-updateone-vs-updatemany?noredirect=1#comment116399692_65831219 | |
'use strict'; | |
const mongoose = require('mongoose'); | |
const { Schema } = mongoose; | |
const DOCUMENTS_COUNT = 1_000_000; | |
const UPDATE_MANY_OPERATIONS_COUNT = 100; | |
const MINIMUM_BALANCE = 0; | |
const MAXIMUM_BALANCE = 100; | |
const SAMPLES_COUNT = 10; |
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
// on the user schema, the address, the city, and the name are all required | |
const user = await User.findOne(filter); | |
// the correct way of accessing the city name | |
const name = user.address.city.name; | |
// the way of accessing the name using optional chaining | |
const name = user?.address?.city?.name; |
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
// When you have a deeply nested object like that | |
// *and you're not sure* whether or not a property exists | |
const user = { | |
address: { | |
city: { | |
name: 'Tokyo' | |
} | |
} | |
}; |
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
Mongo[3568] Starting MongoDB instance with following options: {"port":3568,"dbName":"786c6bf3-3e07-44d8-b297-f03ad6c1a0c0","uri":"mongodb://localhost:3568/786c6bf3-3e07-44d8-b297-f03ad6c1a0c0","storageEngine":"ephemeralForTest","dbPath":"C:\\Users\\Hafez\\AppData\\Local\\Temp\\mongo-mem-10180SoWtC2h2tqGu"} +0ms | |
Mongo[3568] MongoBinary: Mongod binary path: C:\Users\Hafez\.mongodb-binaries\3.4.4\mongod.exe +75ms | |
Mongo[3568] MongoBinary: Download lock removed +29ms | |
Mongo[3568] 2018-06-12T22:51:27.281+0200 I CONTROL [initandlisten] MongoDB starting : pid=3924 port=3568 dbpath=C:\Users\Hafez\AppData\Local\Temp\mongo-mem-10180SoWtC2h2tqGu 64-bit host=Hafez | |
Mongo[3568] +269ms | |
Mongo[3568] 2018-06-12T22:51:27.281+0200 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2 | |
Mongo[3568] 2018-06-12T22:51:27.281+0200 I CONTROL [initandlisten] db version v3.4.4 | |
Mongo[3568] 2018-06-12T22:51:27.281+0200 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd | |
Mong |