These are chat archives for Automattic/mongoose

Sep 2015
Valeri Karpov
Sep 25 2015 00:14
@uptownhr there's a default connection available at mongoose.connection, that's what happens when you do mongoose.connect(). Doing mongoose.model() is the same as mongoose.connection.model().
James Lee
Sep 25 2015 16:17
@vkarpov15 i think my question is more of a node/js question. The mongoose = require('mongoose'), how does that keep the mongoose.connection state across multiple files?
James Lee
Sep 25 2015 17:07


var DataSchema = new Schema({
  properties: {
    title:       { type: String, required: true },
    description: { type: String, required: true },
    date:        { type:Date, }
  geometry: {
       coordinates: { type: [Number], index: '2dsphere'}

is the geometry.coordinations, type: [Number] proper?

does this mean, "coordinates" is an array of Numbers?
Valeri Karpov
Sep 25 2015 17:34
@uptownhr see, require() caches calls
and yep that means coordinates is an array of numbers
James Lee
Sep 25 2015 17:36
damn, i read that before but it is now making sense :)
thank you
@vkarpov15 do you happen to know if browserify would do that same? in regards to caching
Valeri Karpov
Sep 25 2015 20:10
I'm not an expert in browserify but I'd imagine that substack wouldn't leave out such a major detail
and it seems to do that in my experience, but I don't have docs / code to show you as proof unfortunately
James Lee
Sep 25 2015 20:42
@vkarpov15 kk. thanks for the QA. appreciate it
Israel Cruz
Sep 25 2015 23:39
I need my users to be subscribed to tags, so whenever someone creates a post tagged with "xxx" an entry must be created on every subscriptors feed. I've already created models for everything except for subscriptions or tags, what would be the best approach for this in your opinion?
  • Should I make a model named "Tag" and store my tags in there, and then another one called "Subscription" and link them together with a ref?
  • Should I use instead a single model/collection and let every document be a tag, and have a list for its subscriptors?