Skip to content

Instantly share code, notes, and snippets.

@lineus
lineus / output.txt
Last active May 20, 2020
$toObjectId conversion in mongodb aggregation
View output.txt
$: ./vellieswaran.js
All Assertions Pass.
$:
@lineus
lineus / output.txt
Created Nov 8, 2019
gitter population question
View output.txt
gitter: ./pedro.js
[
{
_id: 5dc5aa0e20ccbaa7b8e90b76,
_p_person: { _id: 5dc5aa0e20ccbaa7b8e90b75, name: 'doc', __v: 0 },
__v: 0
},
{
_id: 5dc5aa0e20ccbaa7b8e90b74,
_p_person: { _id: 5dc5aa0e20ccbaa7b8e90b73, name: 'billy', __v: 0 },
@lineus
lineus / output.txt
Created Nov 8, 2019
gitter population question
View output.txt
gitter: ./pedro.js
Error [ValidationError]: story validation failed: _p_person: Cast to ObjectID failed for value "5dc5a219ec0890a15b270acb" at path "_p_person"
at ValidationError.inspect (/Users/lineus/dev/node/mongoose/node_modules/mongoose/lib/error/validation.js:61:24)
at formatValue (internal/util/inspect.js:552:31)
at inspect (internal/util/inspect.js:223:10)
at formatWithOptions (internal/util/inspect.js:1651:40)
at Object.Console.<computed> (internal/console/constructor.js:277:10)
at Object.warn (internal/console/constructor.js:287:61)
at /Users/lineus/dev/node/mongoose/gitter/pedro.js:40:11
at processTicksAndRejections (internal/process/task_queues.js:89:5) {
@lineus
lineus / output.txt
Last active Oct 24, 2019
await and try/catch
View output.txt
node: ./test.js
it was an odd ms.
node:
@lineus
lineus / output.txt
Created Oct 24, 2019
promise with arrows and a catch
View output.txt
node: ./test.js
it was an even ms.
node: ./test.js
it was an odd ms.
node:
@lineus
lineus / index.js
Last active Apr 6, 2018
arrow functions and mongoose (middleware, virtuals, getters/setters, and static/instance methods) don't mix
View index.js
#!/usr/bin/env node
'use strict'
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost/test')
const Schema = mongoose.Schema
const schema = new Schema({
name: String
})
You can’t perform that action at this time.