You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB

  1. // Generated by CoffeeScript 1.6.2
  2. var FileModel, FilesCollection, Model, QueryCollection, _ref, _ref1,
  3. __hasProp = {}.hasOwnProperty,
  4. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  5. _ref = require(__dirname + '/../base'), QueryCollection = _ref.QueryCollection, Model = _ref.Model;
  6. FileModel = require(__dirname + '/../models/file');
  7. FilesCollection = (function(_super) {
  8. __extends(FilesCollection, _super);
  9. function FilesCollection() {
  10. _ref1 = FilesCollection.__super__.constructor.apply(this, arguments);
  11. return _ref1;
  12. }
  13. FilesCollection.prototype.model = FileModel;
  14. FilesCollection.prototype.collection = FilesCollection;
  15. FilesCollection.prototype.fuzzyFindOne = function(data, sorting, paging) {
  16. var file, queries, query, _i, _len;
  17. queries = [
  18. {
  19. relativePath: data
  20. }, {
  21. relativeBase: data
  22. }, {
  23. url: data
  24. }, {
  25. relativePath: {
  26. $startsWith: data
  27. }
  28. }, {
  29. fullPath: {
  30. $startsWith: data
  31. }
  32. }, {
  33. url: {
  34. $startsWith: data
  35. }
  36. }
  37. ];
  38. for (_i = 0, _len = queries.length; _i < _len; _i++) {
  39. query = queries[_i];
  40. file = this.findOne(query, sorting, paging);
  41. if (file) {
  42. return file;
  43. }
  44. }
  45. return null;
  46. };
  47. return FilesCollection;
  48. })(QueryCollection);
  49. module.exports = FilesCollection;