Giter Site home page Giter Site logo

toontoet / meteor-searchin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chompomonim/meteor-searchin

0.0 2.0 0.0 5 KB

Search in Mongo collection for Meteor apps with transliteration support.

Home Page: https://atmospherejs.com/nous/search-in

JavaScript 100.00%

meteor-searchin's Introduction

Meteor searchIn

It's package for Meteor which allows server side search functionality.

Features

  • Indexing of selected fields for faster search.
  • Transliteration. You can search for Rīga by typing riga or Рига.
  • Possibility to use together with chompomonim:autoform-picker.

Usage

First you have register your collection.

import searchIn from 'meteor/chompomonim:search-in'
import myCollection from './collections/myCollection'

if (Meteor.isServer) {
  searchIn.register(myCollection, function () {
    return {
      name: `${this.first_name} ${this.last_name}`,
      email: ((this.emails != null) ? this.emails : []).join(' ')    }
  })
}

And then you can use it in any place you have to search.

  Meteor.call('searchIn', _collection, txt, filter, (error, result) => {
    if (error) {
      alert(error.reason)
    }
    else {
      // Do wathewer you need.
      for (let res of result) {
        console.log('Result obj: ', res)
      }
    }
  })

Usage from client

If you want to search from client, you should write Meteor method for that.

import { Meteor } from 'meteor/meteor';
import { searchIn, getCollectionByName } from 'meteor/nous:search-in'

// Register method to access search function from frontend.
Meteor.methods({
    searchIn: function (collection_name, txt, filter) {
        let collection = getCollectionByName(collection_name)
        return searchIn(collection, txt, filter)
    }
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.