我已经创建了一个方法来检查XML文件中是否存在属性.如果它不存在则返回"False".它可以工作,但解析文件需要很长时间.它似乎读取每一行的整个文件.我错过了什么吗?我可以以某种方式使它更有效吗?
public static IEnumerable<RowData> getXML(string XMLpath)
{
XDocument xmlDoc = XDocument.Load("spec.xml");
var specs = from spec in xmlDoc.Descendants("spec")
select new RowData
{
number= (string)spec.Attribute("nbr"),
name= (string)spec.Attribute("name").Value,
code = (string)spec.Attribute("code").Value,
descr = (string)spec.Attribute("descr").Value,
countObject = checkXMLcount(spec),
return specs;
}
public static string checkXMLcount(XElement x)
{
Console.WriteLine(x.Attribute("nbr").Value);
Console.ReadLine();
try
{
if (x.Attribute("mep_count").Value == null)
{
return "False";
}
else
{
return x.Attribute("mep_count").Value;
}
}
catch
{
return "False";
}
}
Run Code Online (Sandbox Code Playgroud)
我测试用一个只返回和接收字符串的方法替换方法:
public static string checkXMLcount(string x)
{
Console.WriteLine(x);
Console.ReadLine();
return x;
} …
Run Code Online (Sandbox Code Playgroud) 我需要通过在正文中提供几个文档来更新它们.我无法查询它们,必须提供它们.
例:
var persons = [
{id: 1, name'Joe', active: false},
{id:2, name:'Jane', active: false})
];
Run Code Online (Sandbox Code Playgroud)
这个数据在正文中提供,我想将active属性设置为false.
exports.setActivePropertyOnPersons = function(input,callback){
for(var i = 0;i<input.body.length;i++){
mongoose.model('person').findOne({id:input.body[i].id}, function(err, person){
person.active = false;
person.save();
})
}
callback.send(200)
};
Run Code Online (Sandbox Code Playgroud)
这段代码感觉不错.有没有更好的查询来做到这一点?我在文档中找不到任何内容.
尝试使用此软件包:https://www.npmjs.com/package/passport-ldapauth
我设法在medawikiserver(php)中找到了我公司的ldap设置
$wgLDAPDomainNames = array("COMPANY");
$wgLDAPGroupBaseDNs = array("COMPANY"=>"dc=company,dc=se");
$wgLDAPAutoAuthDomain = "COMPANY";
$wgLDAPGroupUseFullDN = array("COMPANY"=>true );
$wgLDAPServerNames = array("COMPANY"=>"dcst.company.se");
$wgLDAPSearchStrings = array("COMPANY" => "COMPANY\\USER-NAME" );
$wgLDAPSearchAttributes = array("COMPANY"=>"sAMAccountName");
$wgLDAPBaseDNs = array("COMPANY"=>"dc=company,dc=se");
$wgLDAPEncryptionType = array("COMPANY" => "ssl" );
$wgMinimalPasswordLength = 1;
Run Code Online (Sandbox Code Playgroud)
我需要将它映射到node-package.我试过这个:
var opts = {
server: {
url: 'ldaps://dcst.company.se',
bindDn: 'dc=company,dc=se',
//bindCredentials: 'secret',
searchBase: 'dc=company,dc=se',
searchFilter: '(&(objectcategory=person)(objectclass=user)(|(samaccountname={{username}})(mail={{username}})))',
searchAttributes: ['displayName', 'mail'],
}
};
Run Code Online (Sandbox Code Playgroud)
我得到"不好的请求".这是来自文档:
badRequestMessage flash message for missing username/password (default: 'Missing credentials')
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
我在自耕农中使用角度发生器.在gruntfile.js中,每个html文件都/app/views
被复制到dist/views
.但我喜欢将指令模板保存在与指令本身相同的文件夹中.
例:
/app/scripts/widgets/mywidget.directive.js
/app/scripts/widgets/mywidget.tmpl.html
Run Code Online (Sandbox Code Playgroud)
当我构建项目时,我希望html文件最终处于与上面相同的文件夹结构中.
这应该可以在gruntfile.js的copy部分中完成.
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,png,txt}',
'*.html',
'images/{,*/}*.{webp}',
'styles/fonts/{,*/}*.*'
]
}...
Run Code Online (Sandbox Code Playgroud)
我试着在src数组中添加它:
'<%= yeoman.dist %>/scripts/{,*/}*.tmpl.html'
Run Code Online (Sandbox Code Playgroud)
不工作.有任何想法吗?
我正在从_id进行$ lookup.所以结果总是1个文件.因此,我希望结果是一个对象,而不是一个包含一个项目的数组.
let query = mongoose.model('Discipline').aggregate([
{
$match: {
project: mongoose.Types.ObjectId(req.params.projectId)
},
},
{
$lookup: {
from: "typecategories",
localField: "typeCategory",
foreignField: "_id",
as: "typeCategory"
}
},
{
$project: {
title: 1, typeCategory: "$typeCategory[0]"
}
}
]);
Run Code Online (Sandbox Code Playgroud)
这种表示法:"$typeCategory[0]"
不起作用.这有什么聪明的方法吗?
当我使用UI Bootstrap http://angular-ui.github.io/bootstrap/中的modal指令时,我没有任何背景.模态本身正在发挥作用.
我尝试过使用ui-bootstrap-tpls.js(包含模板)和没有模板(手动下载).我将标记和css与示例中的标记进行了比较,但我找不到任何区别.一切都在那里.我以前用了好几次,这是我第一次遇到这个问题.这次的不同之处在于我正在使用sass版本的bootstrap.也许与它有关?我想出去的地方.
我的版本:
"angular": "1.2.24",
"angular-animate": "~1.2.24"
"angular-bootstrap": "~0.11.2",
"bootstrap-sass-official": "~3.3.1",
Run Code Online (Sandbox Code Playgroud)
任何人的想法?
我正在使用精湛的插件node-postgres,https://github.com/brianc/node-postgres
我有这个更新休息电话.我的桌子上有大约30列.有没有更简单的方法来更新这些呢?
/*
Post /api/project/products/:pr_id HTTP/1.1
*/
exports.updateProduct = function(req, res){
pg.connect(cs, function(err, client, done) {
var query = "UPDATE products SET pr_title = ($1), pr_usercode = ($2) WHERE pr_id=($3)";
client.query(query, [req.body.pr_title, req.body.pr_usercode, req.params.pr_id], function(err, result) {
if (handleErr(err, done)) return;
done();
sendResponse(res, result.rows[0]);
})
});
};
Run Code Online (Sandbox Code Playgroud)
我这里只有三列.当我写完所有30列时,它将很难维护.必须是一个简单的行更新req.body中所有列的方法?
有任何想法吗?
我有一个函数可以生成一些测试数据并将其插入到 mongodb 中:
'use strict';
const CvFaker = require('./cv-faker');
const mongoose = require('mongoose');
require('../models/cv_model.js');
module.exports.init = function(){
var cvfaker = new CvFaker();
cvfaker.genCvs(100);
mongoose.model('cv').create(cvfaker.cvs, (err, createdCvs) => {
if(err){
console.log('something went wrong');
}
})
};
Run Code Online (Sandbox Code Playgroud)
我想从命令行执行此代码:
node -e 'require("./create-mock-db").init()'
Run Code Online (Sandbox Code Playgroud)
该函数执行,但它不等待函数完成,因为它是异步的。如何让它等待功能完成?
这也不起作用:
module.exports.init = function(cb){ ...
..
cb();
node -e 'require("./create-mock-db").init(function(){})'
Run Code Online (Sandbox Code Playgroud) 有两个收藏,标签和人.
标签型号:
{
en: String,
sv: String
}
Run Code Online (Sandbox Code Playgroud)
人物模型:
{
name: String,
projects: [
title: String,
tags: [
{
type: Schema.ObjectId,
ref: 'tag'
}
]
]
}
Run Code Online (Sandbox Code Playgroud)
我想查询返回人员模型中使用的所有标签.所有文件.
有点喜欢
var query = mongoose.model('tag').find({...});
Run Code Online (Sandbox Code Playgroud)
或者我应该以某种方式使用聚合方法?
在文档中,您可以阅读以下内容:
将Bootstrap导入Sass文件(例如,application.css.scss)以获取Bootstrap的所有样式,mixins和变量!
@import "bootstrap";
Run Code Online (Sandbox Code Playgroud)
https://github.com/twbs/bootstrap-sass
我有几个scss文件.一个用于我的应用程序的每个主要部分(user-page.scss,admin.scsss等).
我尝试在docs中制作一个application.scss和导入的bootstrap.我在bootstrap.scss之后和所有其他scss文件之前在index.html中添加了文件.
<link rel="stylesheet" href="bower_components/bootstrap-sass-official/assets/stylesheets/_bootstrap-compass.scss" />
<link rel="stylesheet" href="styles/application.css">
<link rel="stylesheet" href="styles/intro.css">
<link rel="stylesheet" href="styles/admmin.css">
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
/usr/bin/scss --no-cache --update intro.scss:intro.css
error intro.scss (Line 22: Undefined mixin 'make-row'.)
Run Code Online (Sandbox Code Playgroud)
所以它似乎找不到引导程序.如果我在每个文件中导入bootstrap,它都有效.这是正确的apporach吗?我想不是.当我尝试手动覆盖引导变量时,我遇到了问题.
我怎么能有几个scss文件,只导入一次bootstrap?