我在Google上搜索了几天,我尝试了很多东西,但我仍然无法在我的用户集上进行良好的全文搜索.
我试过ElasticSearch但是查询和分页几乎是不可能的......
我为Mongoose尝试了许多插件,如ElMongo,mongoose-full-text,Mongoosastic等等...每个人都记录不好,我不知道如何进行良好的全文搜索.
所以,我的收藏是一个普通的收藏:
user = {
name: String,
email: String,
profile: {
something: String,
somethingElse: String
}
}
Run Code Online (Sandbox Code Playgroud)
我在页面中有一个简单的搜索输入POST,如果我输入hello world我需要的是在整个集合字段中搜索我的搜索查询的匹配单词并获得结果.
如果有选项可以处理每页10个项目的分页,那将是非常好的...
实现这一目标的最佳解决方案是什么?我正在使用MongoDB 2.6.*与Mongoose,NodeJS和ExpressJS.
谢谢.
我希望创建一个指南针/箭头,就像我们在AroundMe移动应用程序中看到的那样,指向地图上的一个引脚与移动位置相对应,并在我移动手机时更新箭头.
我很难理解如何做到这一点,我找不到任何解释它的指南或教程.
我在网上找到的是一个轴承功能,我围绕它创建了一个指令:
app.directive('arrow', function () {
function bearing(lat1, lng1, lat2, lng2) {
var dLon = (lng2 - lng1);
var y = Math.sin(dLon) * Math.cos(lat2);
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
var rad = Math.atan2(y, x);
var brng = toDeg(rad);
return (brng + 360) % 360;
}
function toRad(deg) {
return deg * Math.PI / 180;
}
function toDeg(rad) {
return rad * 180 / Math.PI;
}
return {
restrict: …Run Code Online (Sandbox Code Playgroud) 我需要一个过滤器来将所有下划线替换为字符串中的空格
我正在使用 Nuxt 和 Vuetify 构建一个大型应用程序,一切都很好并且工作正常,但不幸的是 Lighthouse 的得分并不是最好的,性能只有 42。
我已经改进了一些事情,例如:
nuxtServerInit布局移动到布局中;它从 42 到 54,但我对结果仍然不是很满意。
不幸的是,由于我缺乏知识,我不是最好的进行这些改进。
我认为这TTFB根本不是最佳选择,但我真的不知道我可以改进什么...所以我希望您能通过提示和建议帮助我改进我的应用程序。
在这里,我将粘贴我的,nuxt.congig.js以便您了解我在使用什么以及如何使用:
const path = require('path')
const colors = require('vuetify/es5/util/colors').default
const bodyParser = require('body-parser')
const maxAge = 60 * 60 * 24 * 365 // one year
const prefix = process.env.NODE_ENV === 'production' ? 'example.' : 'exampledev.'
const description =
'description...'
let domain
if (
process.env.NODE_ENV === 'production' &&
process.env.ENV_SLOT === 'staging'
) {
domain = 'example.azurewebsites.net' …Run Code Online (Sandbox Code Playgroud) 从我正在研究的API我需要采用2个不同的列表,我需要接收20个项目的块,以避免服务器超时.
我实际构建的是这样的:
Items1.query().$promise
.then(function (data) {
$scope.items1 = data.list;
return Items2.query().$promise;
})
.then(function (data) {
$scope.items2 = data.list;
});
Run Code Online (Sandbox Code Playgroud)
使用此代码,我正在下载整个对象列表.
两个查询都返回:
{
list: [...],
next: true,
limit: 20,
last: 20
}
Run Code Online (Sandbox Code Playgroud)
基本上它是一个分页系统.
这两种服务都是这样的:
App.factory('Items1', ['$resource',
function($resource) {
return $resource('items1/:item1Id', { storeId: '@id'
}, {
query: {
method: 'GET',
isArray: false
},
update: {
method: 'PUT'
}
});
}
]);
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何使用$ resource创建递归函数,以便将这些项目推送到20个块中.
我想要做的是通过Ajax获取一个json对象,并使用一种值填充Bootstrap Typeahead.
这是我的代码:
nameTypeHead: function () {
var _self = this,
searchInput = $('#nameTypeHead'),
arr = [];
function getArray() {
$.ajax({
url: '/Home/AutoComplete',
type: 'post',
dataType: 'json',
data: { searchText: searchInput.val() },
success: function (data) {
$.each(data, function () {
arr.push(this.Name);
});
return arr;
}
});
}
searchInput.typeahead({
source: getArray()
});
}
Run Code Online (Sandbox Code Playgroud)
我收到arr为null的错误
我也试过.parseJSON()但没有成功:
$.each($.parseJSON(data), function () {
arr.push(this.Name);
});
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能在Typeahed中显示我的Json对象的值Name?
如果在Ajax Success中我alert(JSON.stringify(data));正确地提醒我的Json对象.
我正在构建一个包含产品列表的Nuxt应用程序,然后单击其中一个打开该产品的专用页面。它工作正常。
结构是:
/pages/featured // directory of products
/pages/product/:id/:slug // Dedicated product page
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个新功能:
我希望实现的一个很好的例子是Youpic的 photo 目录。
“产品”列表,完全在带有内部导航的对话框中可见。
我正在查看各种nuxt-routing和vue-router文档以尝试开发它,但我离解决方案还很远。
我在这里看到的一小部分代码看起来与我需要的非常相似,但我不明白我应该如何正确实现它以及如何创建我的 nuxt 自定义路由:
export default {
router: {
extendRoutes (routes, resolve) {
routes.push({
path: '/users/:id',
components: {
default: resolve(__dirname, 'pages/users'), // or routes[index].component
modal: resolve(__dirname, 'components/modal.vue')
},
chunkNames: {
modal: 'components/modal'
}
})
}
}
}
Run Code Online (Sandbox Code Playgroud) 我是stradi的新手,并且通常是在后端开发方面,我试图了解很小的事情应该如何工作。
我有一个用户模型,一个个人资料模型和一个票价模型。
用户可以拥有个人资料,因此我创建了一个关系has and belongs to one。个人资料可以包含票价,而我在个人资料和票价之间创建了相同的关系。
我在这里注意到的是:
在客户端中,我进入个人资料部分时,会使用所有属性(例如名称,姓氏,地址等)进行保存,并且通过向其中添加用户ID一切正常。
这里的要点是,在同一个人资料部分中,我也有票价输入,我想做的是通过保存个人资料而不是仅为票价添加特殊的保存按钮来保存票价...
在这里有可能要做的事情还是我做错了什么?
我正在按配置文件划分票价,以便能够更好地查找,组织和使用票价,而不必每次都查询配置文件,而是通过id ro拥有配置文件记录...
有人可以清楚地解释最佳方法吗?我应该怎么做才能正确实现它?谢谢
我正在研究Mongodb,我正在使用Mongoose,我想创建一个非常动态的注册过程.我使用Passport管理了注册的第一步,一切正常,我创建了用户,它存在于数据库中.现在我的注册过程将继续,用户必须选择"角色":您是什么类型的用户?有两个选项:"基本"和"高级".Basic只有3个属性,advanced有3个基本属性和其他几个属性.
我需要扩展userSchema或添加基于该角色的新字段,但在一周之后它还没有工作,我尝试了很多NPM像:mongoose-relationship或mongoose-schema-extend.
这基本上就是我所拥有的:
userSchema = new Schema({
id : Number,
email : { type: String, required: true },
role : { type: String, required: true },
profile : { ... } // Profile fields are different for each role.
});
// profile 1
basicSchema = new Schema({
info1 : { type: String, required: true },
info2 : { type: String, required: true },
info3 : { type: String, required: true }
}); …Run Code Online (Sandbox Code Playgroud) 我无法摆脱影响我的应用程序功能的小问题,以便能够使用Skype拨打电话号码,到目前为止我所拥有的是:
HTML:
<a ng-href="skype:{{user.phone}}?call" class="btn btn-sm btn-success" type="button">{{user.phone}}</a>
Run Code Online (Sandbox Code Playgroud)
ANGULAR
(function() {
angular.module('core').config(coreConfig);
coreConfig.$inject = ['$compileProvider'];
function coreConfig($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|skype):/);
}
})();
Run Code Online (Sandbox Code Playgroud)
结果总是一样的,当我悬停元素开始调用时,浏览器会显示:unsafe:skype:012345678?call并且不允许我拨打号码...
我添加了配置部分浏览与类似问题相关的其他问题,但它没有解决我的问题.
编辑:我正在使用meanjs.org
编辑2:请不要复制/粘贴我的问题代码作为你的答案...我知道它适用于普通的Angular应用程序.问题是我不能让它使用meanjs.org应用程序.谢谢.
编辑3:我刚刚发现:如果我在主根/或子根中使用skype链接:/list它可以正常工作而不添加unsafe前缀.在动态根目录中:/list/1234它不再起作用.我不知道它是否有帮助.
javascript ×7
angularjs ×4
node.js ×3
express ×2
mongodb ×2
mongoose ×2
nuxt.js ×2
ajax ×1
database ×1
google-maps ×1
jquery ×1
json ×1
ngcordova ×1
performance ×1
production ×1
regex ×1
strapi ×1
vue-router ×1
vue.js ×1
vuetify.js ×1