Skip to content

MikeIbberson/mongoose-partial-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔎 Mongoose partial search plugin

Status Coverage Status

This packages adds a searchBuilder static method to the Mongoose model that returns a case-insensitive, regex-powered query to drop into your find functions.

  const plugin = require('mongoose-partial-search');
  const mongoose = require('mongoose');

  const Schema = new mongoose.Schema({
    name: {
      type: String,
      searchable: true,
    }
  });

  Schema.plugin(plugin);
  
  const Model = mongoose.model('foo', Schema);
  const query = Model.searchBuilder('bar');

  // then, use the query however you like.

Releases

No releases published

Packages

No packages published