These are chat archives for Automattic/mongoose

8th
Dec 2016
bl00mber
@bl00mber
Dec 08 2016 14:22
Why when i run console.log(mongoose) i don't see Schema class but mongoose.Schema is still available? How i can fix logging?
Varun Jayaraman
@varunjayaraman
Dec 08 2016 18:42
its probably a prototype method
/**
 * The Mongoose [Schema](#schema_Schema) constructor
 *
 * ####Example:
 *
 *     var mongoose = require('mongoose');
 *     var Schema = mongoose.Schema;
 *     var CatSchema = new Schema(..);
 *
 * @method Schema
 * @api public
 */

Mongoose.prototype.Schema = Schema;
Varun Jayaraman
@varunjayaraman
Dec 08 2016 18:55
so I have a collection with an index on a nested object's name property, and i want a generic text search to map to this query:
{
      $and: [
       { $or: [
            { $text: { $search: query.text }},
            { 'admin.readableId': query.text }
          ]
        },
        ...additionalQueries
      ]
    }
i want the user to only have to enter the text search in one input and then i want my server to search on that text across multiple fields
i.e. if they type in 690 i want it to run a text search for 690 and also see if the readable id matches 690
when i use this query though, it returns everything in the db
Varun Jayaraman
@varunjayaraman
Dec 08 2016 19:01
ah i think it's related to this:
To use a $text query in an $or expression, all clauses in the $or array must be indexed.
raul
@appsforone_twitter
Dec 08 2016 23:14
how can i make a trivia game with highscore for users