我试图只选择一个特定的字段
exports.someValue = function(req, res, next) {
//query with mongoose
var query = dbSchemas.SomeValue.find({}).select('name');
query.exec(function (err, someValue) {
if (err) return next(err);
res.send(someValue);
});
};
Run Code Online (Sandbox Code Playgroud)
但是在我的json响应中我也收到了_id,我的文档架构只有两个fiels,_id和name
[{"_id":70672,"name":"SOME VALUE 1"},{"_id":71327,"name":"SOME VALUE 2"}]
Run Code Online (Sandbox Code Playgroud)
为什么???
我正在尝试安装MySQLdb扩展,但我得到这个错误,任何想法可能是什么原因?可能是有权限的东西?我正在使用Mac OX Lion ....
这是错误的一部分.Django安装正常,但我需要安装此扩展.谢谢你的帮助.
ppp-071ca:MySQL-python-1.2.4b4 miguel_e$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-intel/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.7-intel-2.7/MySQLdb
running build_ext
building '_mysql' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-
strict-aliasing -fwrapv …Run Code Online (Sandbox Code Playgroud) 我正在为我的PDF文档使用NReco .PdfGenerator(该组件基于WkHtmlToPdf工具),我的代码允许我创建一个pdf,调用一个带有参数controller,action,model的函数:
public static byte[] GeneratePdfDocument(System.Web.Mvc.Controller controller, string viewName, object model)
{
string result;
controller.ViewData.Model = model;
using (StringWriter sw = new StringWriter())
{
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
ViewContext viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
viewResult.View.Render(viewContext, sw);
result = sw.ToString();
}
return (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(result);
}
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以从我的视图中轻松创建PDF,并且它在我的开发环境中运行良好但在服务器上我收到此错误:
The pipe has been ended.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and …Run Code Online (Sandbox Code Playgroud) 我在地图上有一个类库,它继承了两个新类
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Business" namespace="Business.Test">
<class name="BaseExample" table="base_example" abstract="true" discriminator-value="0">
<id name="Id" column="id" type="Int64" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="domain" type="Int16" not-null="true" force="true" />
....
....
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Business" namespace="Business.Test">
<subclass name="Example1" extends="BaseExample" discriminator-value="1">
....
....
</subclass>
</hibernate-mapping>
Run Code Online (Sandbox Code Playgroud)
一切正常,但如果我要求那个领域,例如:
var Clients = ClientFactory.GetAll().Where(c => c.UserData.BaseExample.Domain == 1);
Run Code Online (Sandbox Code Playgroud)
抛出此异常:异常消息:无法解析属性:域:Business.Entities.BaseExample
怎么知道它是一类还是另一类?
我使用Bootstrap插件awesome-bootstrap-ckeckbox,我也在使用ASP.NET MVC,然后我的所有复选框都呈现两个输入,一个作为复选框输入,另一个作为隐藏输入,因为我修改了CSS选择器,例:
HTML代码
<div class="checkbox">
<input id="checkbox1" type="checkbox">
<input type="hidden" />
<label for="checkbox1">
Default
</label>
</div>
<div class="checkbox checkbox-primary">
<input id="checkbox2" type="checkbox" checked>
<input type="hidden" />
<label for="checkbox2">
Primary
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS代码
/* awesome-bootstrap-checkbox */
.checkbox input[type="checkbox"]:checked + label::after {
font-family: 'FontAwesome';
content: "\f00c";
}
.checkbox input[type="checkbox"]:disabled + label::before {
background-color: #eeeeee;
cursor: not-allowed;
}
.checkbox-primary input[type="checkbox"]:checked + label::before {
background-color: #428bca;
border-color: #428bca;
}
.checkbox-primary input[type="checkbox"]:checked + label::after {
color: #fff;
}
/* my own version */ …Run Code Online (Sandbox Code Playgroud) 可以问一下你吗?如何在jQuery的.css()方法中设置负边距(或其他任何值)?我正在按变量添加尺寸,但是不起作用
var width = $('.gallery div img').outerWidth(true);
$('.gallery').css('margin-left', '- ' + width + 'px');
Run Code Online (Sandbox Code Playgroud)
还是有什么方法可以转换var width为负数?
.net ×1
css ×1
django ×1
iis ×1
javascript ×1
jquery ×1
margin ×1
mongodb ×1
mongoose ×1
mysql-python ×1
nhibernate ×1
node.js ×1
orm ×1
python ×1
safari ×1
width ×1
wkhtmltopdf ×1