These are chat archives for Automattic/mongoose

Nov 2017
Paul "Joey" Clark
Nov 16 2017 05:12
@MichaelNey You should give the field name to populate, not the collection name. .populate(“songs”)
Michael Ney
Nov 16 2017 05:47
Yea, I also realized I wasn't even pushing the ID into the user's, so there weren't any ID's to populate based off. ahaha
Abdul-Samii Ajala Olalekan
Nov 16 2017 08:12

I have an appointment schema like this

const mongoose = require('mongoose')
const Schema = mongoose.Schema
const {Mixed, ObjectId} = Schema.Types
const DateType = Schema.Types.Date

let appointmentSchema = new Schema({
  reason: String,
  start: DateType,
  end: DateType,
  appointmentStamp: Number,
  patient: {
    type: String,
    ref: 'Patient'
  doctor: {
    type: String,
    ref: 'Doctor'
  approved: Boolean,
  held: Boolean,
  timeOfAcceptance: Number,
  createdOn: { type: Number, default: (new Date().getTime()) },
  updatedAt: Mixed
}, {runSettersOnQuery: true})

when I run a query with populate like this:

Appointment.find({patient: authId}).populate('patient doctor').exec()

I get an empty array but when I run

Appointment.find({patient: authId}).exec()
Vlado Tesanovic
Nov 16 2017 09:06
 patient: { type: Schema.Types.ObjectId, ref: 'Patient' },
Abdul-Samii Ajala Olalekan
Nov 16 2017 09:21
I dont get you @vladotesanovic
Nov 16 2017 10:32
Hello masterminds. I need to be able to text search a dozen fields in my collection. Is it possible to have a text index that uses all text fields in my collection, but still tell it to search only the 'location' field, for example?
Where the 'location' field is a street address string, not geo data.
Nov 16 2017 21:01
hi everyone. I have a question regarding mongoose ->
I can't for the life of me get the ref to save nor populate...nothing is working. My Mongoose version is "mongoose": "^4.13.2",