Skip to content

Instantly share code, notes, and snippets.

View harpreetkhalsagtbit's full-sized avatar

Harpreet Singh harpreetkhalsagtbit

View GitHub Profile
@harpreetkhalsagtbit
harpreetkhalsagtbit / saveAndPushIdAndSaveParent.js
Created June 22, 2014 17:43
Save after push to a refrence model
var async = require('async');
global._clients = {};
var mongoose = require('mongoose');
global._mongoose = mongoose;
var conf = {
db: {
db: 'gendocx',
host: 'localhost',
@harpreetkhalsagtbit
harpreetkhalsagtbit / populateMultipleTables.js
Last active August 29, 2015 14:02
Populate Multiple Tables - Result of each populate is an array
// working example mongoose
var tableASchema = new Schema({
template : String,
description : String
});
var tableBSchema = new Schema({
group : String,
a_pk : [{ type: Schema.ObjectId, ref: 'tableA' }],
@harpreetkhalsagtbit
harpreetkhalsagtbit / dynamicMongooseMultipleQuerie
Last active April 6, 2021 08:02
Running multiple Mongodb/mongoose queries - dynamiclly using async.js
// working example mongoose
var PersonSchema = new Schema({
name : String,
age : Number,
});
var StorySchema = new Schema({
title : String,
});
var Story = mongoose.model('Story', StorySchema);
var Person = mongoose.model('Person', PersonSchema);
@harpreetkhalsagtbit
harpreetkhalsagtbit / GeoNamesCountries
Last active December 29, 2015 13:32
Geo Names Countries
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},
{
@harpreetkhalsagtbit
harpreetkhalsagtbit / GeoNameJsonIndianStates
Created May 29, 2014 09:45
Indian States Geo Names JSON
[
{
"name": "Andaman and Nicobar Islands",
"code": "AN"
},
{
"name": "Andhra Pradesh",
"code": "AP"
},
{