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
62 lines
1.7 KiB
// Generated by CoffeeScript 1.6.3
|
|
var FileModel, FilesCollection, Model, QueryCollection, pathUtil, _ref, _ref1,
|
|
__hasProp = {}.hasOwnProperty,
|
|
__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; };
|
|
|
|
pathUtil = require('path');
|
|
|
|
_ref = require('../base'), QueryCollection = _ref.QueryCollection, Model = _ref.Model;
|
|
|
|
FileModel = require('../models/file');
|
|
|
|
FilesCollection = (function(_super) {
|
|
__extends(FilesCollection, _super);
|
|
|
|
function FilesCollection() {
|
|
_ref1 = FilesCollection.__super__.constructor.apply(this, arguments);
|
|
return _ref1;
|
|
}
|
|
|
|
FilesCollection.prototype.model = FileModel;
|
|
|
|
FilesCollection.prototype.collection = FilesCollection;
|
|
|
|
FilesCollection.prototype.fuzzyFindOne = function(data, sorting, paging) {
|
|
var escapedData, file, queries, query, _i, _len;
|
|
escapedData = data != null ? data.replace(/[\/]/g, pathUtil.sep) : void 0;
|
|
queries = [
|
|
{
|
|
relativePath: escapedData
|
|
}, {
|
|
relativeBase: escapedData
|
|
}, {
|
|
url: data
|
|
}, {
|
|
relativePath: {
|
|
$startsWith: escapedData
|
|
}
|
|
}, {
|
|
fullPath: {
|
|
$startsWith: escapedData
|
|
}
|
|
}, {
|
|
url: {
|
|
$startsWith: data
|
|
}
|
|
}
|
|
];
|
|
for (_i = 0, _len = queries.length; _i < _len; _i++) {
|
|
query = queries[_i];
|
|
file = this.findOne(query, sorting, paging);
|
|
if (file) {
|
|
return file;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
return FilesCollection;
|
|
|
|
})(QueryCollection);
|
|
|
|
module.exports = FilesCollection;
|