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.

62 lines
1.7 KiB

  1. // Generated by CoffeeScript 1.6.3
  2. var FileModel, FilesCollection, Model, QueryCollection, pathUtil, _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. pathUtil = require('path');
  6. _ref = require('../base'), QueryCollection = _ref.QueryCollection, Model = _ref.Model;
  7. FileModel = require('../models/file');
  8. FilesCollection = (function(_super) {
  9. __extends(FilesCollection, _super);
  10. function FilesCollection() {
  11. _ref1 = FilesCollection.__super__.constructor.apply(this, arguments);
  12. return _ref1;
  13. }
  14. FilesCollection.prototype.model = FileModel;
  15. FilesCollection.prototype.collection = FilesCollection;
  16. FilesCollection.prototype.fuzzyFindOne = function(data, sorting, paging) {
  17. var escapedData, file, queries, query, _i, _len;
  18. escapedData = data != null ? data.replace(/[\/]/g, pathUtil.sep) : void 0;
  19. queries = [
  20. {
  21. relativePath: escapedData
  22. }, {
  23. relativeBase: escapedData
  24. }, {
  25. url: data
  26. }, {
  27. relativePath: {
  28. $startsWith: escapedData
  29. }
  30. }, {
  31. fullPath: {
  32. $startsWith: escapedData
  33. }
  34. }, {
  35. url: {
  36. $startsWith: data
  37. }
  38. }
  39. ];
  40. for (_i = 0, _len = queries.length; _i < _len; _i++) {
  41. query = queries[_i];
  42. file = this.findOne(query, sorting, paging);
  43. if (file) {
  44. return file;
  45. }
  46. }
  47. return null;
  48. };
  49. return FilesCollection;
  50. })(QueryCollection);
  51. module.exports = FilesCollection;