之间有什么区别:
DB::table('some_table')
->selectRaw('COUNT(*) AS result')
->get();
Run Code Online (Sandbox Code Playgroud)
和:
DB::select(DB::raw("
SELECT COUNT(*) AS result
FROM some_table"));
Run Code Online (Sandbox Code Playgroud)
他们在文档https://laravel.com/docs/5.6/queries中广告有关使用raw()适当的SQL注入,但是与selectRaw?相同。
我有两个<select>输入。我想将属性设置为“禁用”其中一个的特定值选项<select>。
第一个是:
<select ref="selectOption">
<option selected value="1" >Option 1</option>
<option value="2" >Option 2</option>
</select>
<select ref="selectTime" disabled={this.state.disabled}>
<option value="a" >January</option>
<option value="b" >Febreaury</option>
</select>
Run Code Online (Sandbox Code Playgroud)
所以,我的想法是<select>当第一个选项值 = 2 时将第二个的状态设置为 false<select>
我该怎么做?还是有另一种没有反应的方法我可以做到?还是带道具?我很困惑。我试图做这样的事情:
var option= ReactDom.findDOMNode(this.refs.selectOption).value;
if( option == '2' ) this.setState({disabled:true});
Run Code Online (Sandbox Code Playgroud)
但它不起作用。试图将它放在 componentDidUpdate 中,但是当我从选择中选择一个新值时组件没有更新,所以这不起作用。想法请。
编辑:
我也有 jquery 的这个解决方案,但我想使用 Reactjs。
$('#selectOption').change(function() {
$('#selectTime').prop('disabled', false);
if ($(this).val() == '2') {
$('#selectTime').prop('disabled', true);
}
})
Run Code Online (Sandbox Code Playgroud)
我很困惑如何使用 ReactDom.findDOMNode(this.refs.selectOption) 而不是 jquery 选择器
当我执行此查询时,我没有问题:
SELECT a.value, b.label AS campo, 'date' AS tipo
FROM contenido.field_value_textarea a
JOIN estructura.field b ON a.field=b.id
WHERE a.value LIKE '%aaa%'
Run Code Online (Sandbox Code Playgroud)
contenido.field_value_textarea是 character varying(2000)
但是,如果我尝试选择:
contenido.field_value_fecha哪个类型是date我收到此错误消息:
错误:运算符不存在:date ~~ unknown
我想要做的是在不同的表之间进行搜索,每个查询都选择FROM它的表.有些表使用文本值,textarea值,整数值,并且它可以工作,但是当值date全部失败时.我能做什么?
编辑:顺便说一句,我的日期值是这样的:2009-05-01
在本地环境中我没有问题,但是使用此脚本在 jenkins 上运行生产环境确实可以:
yarn install --production
yarn build
Run Code Online (Sandbox Code Playgroud)
构建大约需要 5 分钟,最后,jenkins 退出并显示此控制台输出错误:
+ yarn install --production
yarn install v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
warning " > bootstrap@4.3.1" has unmet peer dependency "popper.js@^1.14.7".
warning " > google-maps-react@1.1.11" has incorrect peer dependency …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Postman 通过 Graphql 调用服务。从我的应用程序 (React) 中,我可以毫无问题地使用所有服务(因此,它们运行正常),但我想用 Postman 单独测试它们。
我正在使用 AppSync,这是我的配置:
const AppSyncConfig = {
url: environments.configAws.graphql.aws_appsync_graphqlEndpoint,
region: environments.configAws.graphql.aws_appsync_region,
auth: {
type: AUTH_TYPE.API_KEY,
apiKey: environments.configAws.graphql.aws_appsync_apiKey,
}
};
Run Code Online (Sandbox Code Playgroud)
环境变量是这样的:
graphql: {
aws_project_region: "us-east-1",
aws_appsync_graphqlEndpoint: "https://XXXXXXXXXXXXX.appsync-api.us-east-1.amazonaws.com/graphql",
aws_appsync_region: "us-east-1",
aws_appsync_authenticationType: "API_KEY",
aws_appsync_apiKey: "da2-XXXXXXXXXXXX"
}
Run Code Online (Sandbox Code Playgroud)
该应用程序使用它来进行查询:
const client = new AWSAppSyncClient(AppSyncConfig, {
link: createAppSyncLink({ ...AppSyncConfig,
resultsFetcherLink: ApolloLink.from([
setContext((request, previousContext) => ({
headers: { ...previousContext.headers,
Authorization: localStorage.getItem('token') ? localStorage.getItem('token') : ''
}
})),
createHttpLink({
uri: AppSyncConfig.url
})
])
})
});
const data_configs = client.readQuery({ query: …Run Code Online (Sandbox Code Playgroud) 我有 5 个 NodeJS 服务在运行,但其中一个有问题。
这是nodemon.json文件:
{
"watch": ["**/*.ts"],
"ext": "ts,json",
"ignore": ["./test/*.ts"],
"exec": "node -r ts-node/register -r dotenv/config Index.ts dotenv_config_path=$(pwd)/.env",
"env": {
"NODE_ENV": "development"
}
}
Run Code Online (Sandbox Code Playgroud)
它与其他服务相同。当我运行时,npm run dev我收到错误消息,具体取决于从 .env 文件中获取的值,例如:
const LOCAL_CONFIGURATION = {
PORT_APP: 8082,
MONGODB: {
SERVER: process.env.MONGO_DTE,
AUTH: {
auth: {
password:process.env.MONGO_PASSWORD,
user:process.env.MONGO_USER
}
},
},
MS_NOTIFICACION: "http://localhost:8089/notificacion",
ELASTIC_PATH: process.env.ELASTIC_PATH,
...COMMON,
};
Run Code Online (Sandbox Code Playgroud)
第一条错误消息是:
ConfigurationError: Missing node(s) option
产生该消息是因为它没有从 读取值process.env.ELASTIC_PATH,但是如果我放置了一个像“ http://with.the.correct.url ”这样的硬编码值,然后它再次尝试运行,我会收到另一个错误:
Error: Credentials must be provided when creating a …
我有一个React这样的动作:
export const sigIn = () =>
async (dispatch: any) => {
dispatch({
type: SIGN_IN_REQUEST
});
};
Run Code Online (Sandbox Code Playgroud)
我得到一个:
ESLint: Argument 'dispatch' should be typed with a non-any type.(@typescript-eslint/explicit-module-boundary-types)
Run Code Online (Sandbox Code Playgroud)
作为对 的警告async。为什么?
编辑:对于这两个答案,我输入了类型Dispatch,redux但仍然有警告:
我正在读取一个 excel 文件的一列,其值类似于“1:45:00。但是当print_r($value["time"])我的数组中的这个值时,我得到了一个像这样的 Carbon 对象:
Carbon\Carbon Object
(
[date] => 2018-10-30 01:45:00.000000
[timezone_type] => 3
[timezone] => America/US
)
Run Code Online (Sandbox Code Playgroud)
然后,当我插入一个批量数组时,我的值是:
"time"=>$value["time"]
Run Code Online (Sandbox Code Playgroud)
在数据库中我得到: 2018-10-30 01:45:00
如何仅插入01:45:00而不是整个时间戳?
编辑:我认为这$value["time"]->date->format("H:i:s")会起作用,但我收到错误“试图获取非对象的属性‘日期’”
编辑 2:这就是我读取数据的方式:
excel是这样的:
date time
---------- -------
30-10-2018 01:45:00
Run Code Online (Sandbox Code Playgroud)
我读取excel的代码:
$data = Excel::selectSheetsByIndex(0)->load($path, function($reader) {
})->get()->toArray();
foreach ($data as $key => $value) {
$time = Carbon::createFromFormat('Y-m-d h:i:s',$value["time"])->format('h:i:s');
print_r($time);
die();
}
Run Code Online (Sandbox Code Playgroud)
输出:
Call to a member function format() on null
我有这个测试:
const rendered = render(
<TransactionReason
reason={{ code: defaultReason }}
/>
);
expect(rendered.getByTestId('reasonInput')).toBeNull();
Run Code Online (Sandbox Code Playgroud)
我想做的是:有一个组件具有,但是当prop 具有我给出的值testID = 'reasonInput'时,该组件不会呈现(代码:defaultReason)。reason但我收到一个错误,因为 Jest 找不到该 id,当然,它没有呈现。我认为这会产生一个 false 或 null 值,这就是为什么我尝试使用toBeNullortoBeFalsy或类似的东西。
那么我如何测试该组件是否存在?
这是一组控制器的列表:
Route::group([
'prefix' => 'some-prefix',
], function () {
Route::get('/', 'MyController@index')->name('some-prefix');
Route::post('/get', 'MyController@getData')->name('some-prefix.get');
Route::get('/getall/{type}', 'MyController@getAllData')->name('some-prefix.getall');
Route::get('/create', 'MyController@create')->name('some-prefix.create');
Route::post('/', 'MyController@store')->name('some-prefix.store');
Route::get('/edit', 'MyController@edit')->name('some-prefix.edit');
Route::get('/{id}/edit/', 'MyController@edit')->name('some-prefix.edit');
Route::put('/{id}', 'MyController@update')->name('some-prefix.update');
Route::get('/cambiarestado/{id}', 'MyController@cambiarestado')->name('some-prefix.cambiarestado');
});
Run Code Online (Sandbox Code Playgroud)
我在键入URL时要重定向到404错误:
http://myapp.com/some-prefix/ANYTHING-that-doesnt-match
Run Code Online (Sandbox Code Playgroud)
这是我收到下一个错误的时候:
(1/1) MethodNotAllowedHttpException
in RouteCollection.php (line 251)
at RouteCollection->methodNotAllowed(array('PUT'))
in RouteCollection.php (line 238)
at RouteCollection->getRouteForMethods(object(Request), array('PUT'))
in RouteCollection.php (line 176)
Run Code Online (Sandbox Code Playgroud)
我在我的控制器中添加了一个failOrFind内部store和edit方法,因此我可以重定向404路由,如:
http://myapp.com/some-prefix/9999/edit
Run Code Online (Sandbox Code Playgroud)
价值9999不存在的地方,但我怎么能按照我的要求去做?
laravel ×3
reactjs ×3
php ×2
aws-appsync ×1
dotenv ×1
graphql-js ×1
javascript ×1
jestjs ×1
node-modules ×1
node.js ×1
php-carbon ×1
postgresql ×1
react-apollo ×1
routes ×1
setstate ×1
sql ×1
typescript ×1
yarnpkg ×1