jss:anti-search-source 1.4.2

Flexible search in collections based on publish/subscribe

Platform: Meteor

Language: JavaScript

License: MIT

Repository: https://github.com/JSSolutions/meteor-anti-search-source

View on registry: https://atmospherejs.com/jss/anti-search-source

Install: meteor add jss:anti-search-source@=1.4.2


jss:anti-search-source

Flexible search in collections based on publish/subscribe

Features

  • Search by multiple fields
  • Searched fields transform
  • Search in local or global mode
  • High security level in global mode
  • Search in relatives collections

Search configuration

  • collection - instance of collection to search in;
  • searchMode - where search: "global" (server) or "local" (client);
  • fields - fields to search by. Also, support search in related collections;
  • mongoQuery - additional Mongo query;
  • limit - count of documents in result.

Client methods

  • search('stringToSearch') - changes search string;
  • searchResult([options]) - return search result as Mongo.Cursor (Array for 'global' search). options work similarly to Meteor collection find()'s. Reactive data source;
  • setMongoQuery(newMongoQuery) - replaces Mongo query from configuration
  • setLimit(newLimit) - change limit;
  • incrementLimit([increment=10]) - increase limit on value.

Usage example

Persons = new Mongo.Collection('persons');

if (Meteor.isClient) {
  Template.hello.onCreated(function () {
    this.searchSource = this.AntiSearchSource({
      collection: Persons,
      searchMode: 'global',
      fields: ['name', 'email', {
          collection: 'groups',
          referenceField: 'groupId',
          fields: ['groupDescription']
      }, {
          collection: 'home',
          referenceField: 'homeId',
          fields: ['homeDescription','otherField']
      }],
      mongoQuery: {
        age: {$gte: 30}
      },
      limit: 10
    });
  });

  Template.hello.helpers({
    searchResult: function () {
      return Template.instance().searchSource.searchResult();
    }
  });

  Template.hello.events({
    'keyup input': _.throttle(function (event, tmpl) {
      tmpl.searchSource.search($('input').val())
    }, 1500)
  });
}

if (Meteor.isServer) {
  AntiSearchSource.allow('persons', {
    maxLimit: 20,
    securityCheck (userId, configs) {
      return !!userId;
    },
    allowedFields: ['name', 'email']
  });
}

Changelog

  • 1.3.0 - Translated to ES6, fully refactored, added search by related documents.

Made by Professional Meteor Development Studio - Professional Meteor Development Company

Releases

1.4.2 December 20, 2016
1.4.0 July 25, 2016
1.3.2 June 29, 2016
1.3.1 May 27, 2016
1.3.0 May 24, 2016
1.2.0 May 13, 2016
1.1.0 May 12, 2016
1.0.2 March 01, 2016

Project Statistics

SourceRank 11
Dependent repositories 0
Total releases 8
Latest release
First release
Stars 6
Forks 2
Watchers 13
Contributors 4
Repo Size: 44.9 KB

Top Contributors See all

trsdln Vadym Vorobel IuriiBod VolodymyrTymets

Something wrong with this page? Make a suggestion

Export .ABOUT file for this library

Last synced: 2016-12-21 08:12:05 UTC

Login to resync this project