正如标题所示,我遇到了mongoose save方法的问题,这种方法失败但不会产生错误.
我实际上知道它为什么失败,这是由于userId字段被标记为必需但没有提供...但我不知道它为什么不抛出错误.我已经筋疲力尽了谷歌和stackoverflow看着类似的建议没有运气,所以把它打开给任何可以帮助我的人!
这是代码......
Model.js
var mongoose = require('mongoose');
var TimeSchema = new mongoose.Schema({
client: String,
matter: String,
activity: String,
tags: String,
description: String,
comments: [String],
startTime: Date,
startTimeUTC: Number,
endTime: Date,
endTimeUTC: Number,
duration: Number,
durationRnd: Number,
durationUnits: Number,
billable: Boolean,
rate: Number,
total: Number,
user: String,
userId: { type: mongoose.Schema.ObjectId, required: true }
}, {safe: true});
mongoose.model("Time", TimeSchema);
Controller.js
exports.addTime = function (req, res) {
console.log('Adding time: ' + JSON.stringify(req.body));
var time = new Time(req.body);
time.save(function (err) { …Run Code Online (Sandbox Code Playgroud) 您好我尝试在eclipse中运行以下cmd代码:
"DIR \""+DEV_HOME+"\\src\"\\*.java /b /s >> \""+DEV_HOME+"\\bin\\javaFiles.txt\""
Run Code Online (Sandbox Code Playgroud)
显然它看起来像这样:
DIR "D:\Thomas\Dokumente\Daten\workspace\WBRLight\src"\*.java /b /s >> "D:\Thomas\Dokumente\Daten\workspace\WBRLight\bin\javaFiles.txt"
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误消息:
java.io.IOException: Cannot run program "dir": CreateProcess error=2, Das System kann die angegebene Datei nicht finden
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
....
Run Code Online (Sandbox Code Playgroud)
当我尝试在cmd框中使用代码时,它的工作正常.我的代码:
public void run_cmdLine(String command) {
try {
Runtime rt = Runtime.getRuntime();
BufferedReader input = null;
Process pr = null;
pr = rt.exec(command);
input = new BufferedReader(new inputStreamReader(pr.getInputStream()));
String line = null;
while ((line = input.readLine()) != null) {
System.out.println(line);
}
int exitVal …Run Code Online (Sandbox Code Playgroud) 我正在使用这里找到的教程:http://addyosmani.github.io/backbone-fundamentals/#create-a-simple-web-server并添加了以下代码.
// Module dependencies.
var application_root = __dirname,
express = require( 'express' ), //Web framework
path = require( 'path' ), //Utilities for dealing with file paths
mongoose = require( 'mongoose' ); //MongoDB integration
//Create server
var app = express();
// Configure server
app.configure( function() {
//parses request body and populates request.body
app.use( express.bodyParser() );
//checks request.body for HTTP method overrides
app.use( express.methodOverride() );
//perform route lookup based on url and HTTP method
app.use( app.router );
//Where …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用index.js桶导出默认模块,但似乎无法使其工作.它适用于命名导出,但不适用于默认导出.
简化的项目结构
/hellos
/components
Hello.js
Hellos.js
index.js
index.js
App.js
Run Code Online (Sandbox Code Playgroud)
/hellos/component/Hellos.js
...
export default Hellos
Run Code Online (Sandbox Code Playgroud)
/hellos/component/index.js
export * from './Hello';
export * from './Hellos';
Run Code Online (Sandbox Code Playgroud)
/hellos/index.js
export * from './components'
export * from './actions'
export * from './constants'
export * from './reducers'
Run Code Online (Sandbox Code Playgroud)
App.js
import Hellos from './hellos'
console.log(Hellos) // <- undefined
Run Code Online (Sandbox Code Playgroud)
上面导入的Hellos模块始终未定义.
我可以使用命名导出或App.js中的直接导入来使用它,import Hellos from './hellos/component/Hellos'但我认为这是一种不好的做法,只是希望使用import Hellos from '/hellos'.
我怀疑问题出在index.js桶上,但我无法解决问题.请帮忙.
我想将Twitter Bootstrap用于一个有点疯狂布局的项目.
徽标的背景应从窗口边缘开始,但徽标中的文本应从开始的位置.container开始.疯了,呵呵!
到目前为止我所做的是:
<div class="container">
<header>
<div id="logo" class="pull-left col-sm-3 bg-theme">
<div class="typography">
Dope
<br/>
Text
</div>
</div>
<div class="col-sm-9">
<nav class="pull-right"> nav should be here </nav>
</div>
</header>
<!-- header -->
</div>
#logo {
position: relative;
height: 100px;
background: #ffd800;
}
.typography {
position: absolute;
right: 0px;
top: 20px;
line-height: 50px;
font-size: 50px;
font-weight: bold;
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个演示@ jsFiddle.
我应该如何构建我的HTML,或者我可以用CSS做些什么来实现这种效果.
只有CSS的解决方案.
编辑:那些标题元素可能会再次出现在页面上,因此基于元素将位于页面顶部的事实的解决方案不是我所追求的.
我刚刚了解了React Fragments。
我了解到,通过创建更少的树节点,片段可以稍微提高效率,并且在查看检查器时可使片段更整洁,但是那为什么我们还要在React组件中用作容器?我们应该始终在组件中使用React.Fragments吗?
使用片段会增加样式难度吗?(我不确定,因为我还没有尝试过)。
我正在使用angular2构建单页面应用程序,它需要根据应用程序的路由呈现不同的应用程序模板.在最高级别,它应该能够在主应用程序模板和应用程序的管理模板之间切换.
路由规则:
执行:
为了实现这一点,我有一个最高级别的组件应用程序,它将责任委托给AuthApp或MainApp,就像这样.
@RouteConfig([
{
path: '/auth/...',
component: AuthApp,
as: 'Auth'
},
{
path: '/...',
component: MainApp,
as: 'Main'
}
])
Run Code Online (Sandbox Code Playgroud)
然后每个子应用程序(例如AuthApp,MainApp)都有自己的路由定义,例如这个.
@RouteConfig([
{ path: '/current-vacancies', CurrentVacancies, as: 'CurrentVacancies', useAsDefault: true },
{ path: '/candidates/create', CandidateCreate, as: 'CandidateCreate'},
...
])
Run Code Online (Sandbox Code Playgroud)
功能上,从设计的角度来看,这非常有用!
问题:
在主应用程序中,应用程序的路由配置未指定路径(例如/...=> MainApp),我不想要嵌套的URL路径.例如,如果您通过应用程序(routerLink)导航到CurrentVacancies,它会更新网址并预先添加额外的不需要的正斜杠..../#//current-vacancies当我希望它读取时,url路径现在看起来像这样.../#/current-vacancies.
当您.../#/current-vacancies在地址栏中键入时,应用程序路由实际工作正常,它会正确转换.然而,通过应用程序routerLink指令进行导航会预先添加不需要的正斜杠.
我从逻辑上理解为什么会发生这种情况,委托给MainApp的根组件有一个'/'路径,它与它的子组件连接在一起形成一个完整的url路径.但在这种情况下,不希望有额外的斜线.任何想法我如何删除它,或以某种方式覆盖此行为.
顺便说一下,我考虑过将MainApp组件路由移到最顶层,虽然这确实解决了我报告的url路径问题,但它不允许我在顶层切换模板.
综上所述
请帮帮我
/主应用程序路由上不需要的内容"preferred option",或谢谢
我一直在撞墙试图让这个工作,任何建议?我正在使用这里的流量反应.我正在努力理解这段代码注释的东西,我正在同时学习.起初它是压倒性的,但在我花了一些时间在谷歌搜索任何远程关闭后,我已经走到了尽头.救命?
//@flow
import React, { Component } from 'react';
import ShowCard from './ShowCard';
import Header from './Header';
type Props = {
shows: Array<Show>
};
type State = {
searchTerm: " "
};
class Search extends Component<Props, State> {
handleSearchTermChange = (Event: SyntheticKeyboardEvent<KeyboardEvent> & { currentTarget: HTMLInputElement }) => {
//this.setState({ searchTerm: event.currentTarget.value });
const newState = this.setState({ searchTerm: Event.currentTarget.value });
return newState;
};
render() {
return (
<div className="search">
<Header searchTerm={this.state.searchTerm} showSearch handleSearchTermChange={this.handleSearchTermChange} />
<div>
{this.props.shows
.filter(
show =>
`${show.title} …Run Code Online (Sandbox Code Playgroud) 我想在我的NodeJS.Timer一个类中使用类型作为类型注释:
const interval: NodeJS.Timer = setInterval(this._func, 1000)
Run Code Online (Sandbox Code Playgroud)
我该如何导入这种类型?我正在使用流量.
我不确定用户定义的类对象是如何被垃圾收集的.我是否需要在每个类上实现IDisposable接口并调用其上的dispose()方法来释放内存?
javascript ×5
flowtype ×2
node.js ×2
reactjs ×2
angular ×1
asp.net ×1
c# ×1
cmd ×1
css ×1
eclipse ×1
es6-modules ×1
express ×1
html ×1
ioexception ×1
java ×1
mongoose ×1
oop ×1
react-native ×1
routes ×1
setstate ×1