elastic-database-pool 相关问题


如何在Elastic Beanstalk上正确安装Python应用程序包?

我正在尝试在 Elastic Beanstalk 上部署 Python 应用程序。我知道如何安装其他Python需求(即使用requirements.txt),但我不确定安装应用程序包的最佳方法


在多处理过程中抑制输出

我有一些使用多处理 Pool 类并行运行的代码。不幸的是,我从另一个库使用的一些函数有一些详细的输出。要抽象问题有...


如何创建松果客户端,它给出错误

存在于松果.ts 中 从 '@pinecone-database/pinecone' 导入 { PineconeClient } 导出 const getPineconeClient = async () => { const client = new PineconeClient() 等待客户。


Golang elasticsearch TypedClient 聚合如何循环结果

我正在使用 Elastic 的官方 Elasticsearch Go Typed Client 包来查询 uniq 服务名称,为此我构建了一个聚合搜索。查询成功,响应包含Bu...


laravel 中的具体迁移回滚

我正在尝试回滚一项特定迁移。 我正在使用 php artisan migrate:rollback --path=database/migrations/2023_09_04_051650_create_tickets_table.php 在本地主机上,它回滚该迁移...


带有 tcp 输入插件的 Logstash 不转发日志

我的本地计算机上运行着四个容器(Elastic search (8.10.2)、Logstash、Kibana 和我的应用程序容器),并且应用程序配置为将日志转发到 Logstash。我是


Elastic APM 服务器在 Docker 中不可用

我正在尝试运行 apm-server 使用 apm-agent 从基于 java 的应用程序收集并发送给 Elasticsearch。 这是我的撰写文件: 服务: 订单服务: 图片:apm-java/order-service:1.0.0 ...


UTL_SMTP.WRITE_DATA 修剪电子邮件正文中的多余空格 |甲骨文

Oracle Database 19c 企业版版本 19.0.0.0.0 - 生产 版本 19.20.0.0.0 我正在使用 UTL_SMTP 发送电子邮件。下面是代码 宣布 l_mail_conn UTL_SMTP.connection; l_bo...


如何使用 ElasticsearchClient 将“analyzer”:“french”条目添加到 Elastic 映射属性?

我正在从 Java 对象创建弹性索引。 公共课 JeuDeDonnees { 私有字符串标题; 私有字符串段; 私有字符串缩写; 私有字符串 url; 私人组织...


通过雄辩的模型执行查询后,如何查看我的 mssql 服务器中运行的查询?

在我的 Laravel Tinker 会话中,我运行以下命令: $records = MyModel::with('parent','children')->whereNull('parent_id')->get(); 模型是: 命名空间 App\Models; 使用 Illuminate\Database\


如何在 AWS Elastic Beanstalk 环境/应用程序中运行 artisan migrate?

我已经完成了所有这些事情来部署我的应用程序,但我无法在部署中运行 php artisan migrate。我已经尝试了从container_commands到.ebextensions/.platform/hooks的许多解决方案,但没有任何效果......


为什么在VB.NET中没有出现Binding Combobox usingdictionary with the MS ACCESS database with dapper

我正在尝试使用VB.NET中的dapper将字典与MS ACCESS数据库绑定组合框。 所以我希望使用字典的绑定出现在组合框中,这是表的结果


Illuminate\Database\Grammar::parameterize():参数 #1 ($values) 必须是数组类型,给定站点的字符串:stackoverflow.com

我尝试用 eloquent 将数据保存在 json 中,但遇到了这个问题,我不知道为什么会收到此错误。 =====================我的控制器===================== 公共函数facture_save(请求$


Laravel POST 方法返回状态:405 不允许在 POST 方法上使用方法

请查找以下信息: NoteController.php 请查找以下信息: NoteController.php <?php namespace App\Http\Controllers; use App\Http\Requests\NoteRequest; use App\Models\Note; use Illuminate\Http\JsonResponse; class NoteController extends Controller { public function index():JsonResponse { $notes = Note::all(); return response()->json($notes, 200); } public function store(NoteRequest $request):JsonResponse { $note = Note::create( $request->all() ); return response()->json([ 'success' => true, 'data' => $note ], 201); } public function show($id):JsonResponse { $note = Note::find($id); return response()->json($note, 200); } public function update(NoteRequest $request, $id):JsonResponse { $note = Note::find($id); $note->update($request->all()); return response()->json([ 'success' => true, 'data' => $note, ], 200); } public function destroy($id):JsonResponse { Note::find($id)->delete(); return response()->json([ 'success' => true ], 200); } } NoteRequest.php <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class NoteRequest extends FormRequest { public function authorize() { return true; } public function rules() { return [ 'title', 'required|max:255|min:3', 'content', 'nullable|max:255|min:10', ]; } } Note.php(模型) <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Note extends Model { use HasFactory; protected $guarded = []; } api.php <?php use App\Http\Controllers\NoteController; use Illuminate\Support\Facades\Route; Route::prefix('v1')->group(function () { Route::resource('/note', NoteController::class); }); php artisan 路线:列表 GET|HEAD / ...................................................................................................................... POST _ignition/execute-solution ............... ignition.executeSolution › Spatie\LaravelIgnition › ExecuteSolutionController GET|HEAD _ignition/health-check ........................... ignition.healthCheck › Spatie\LaravelIgnition › HealthCheckController POST _ignition/update-config ........................ ignition.updateConfig › Spatie\LaravelIgnition › UpdateConfigController GET|HEAD api/v1/note .......................................................................... note.index › NoteController@index POST api/v1/note .......................................................................... note.store › NoteController@store GET|HEAD api/v1/note/create ................................................................. note.create › NoteController@create GET|HEAD api/v1/note/{note} ..................................................................... note.show › NoteController@show PUT|PATCH api/v1/note/{note} ................................................................. note.update › NoteController@update DELETE api/v1/note/{note} ............................................................... note.destroy › NoteController@destroy GET|HEAD api/v1/note/{note}/edit ................................................................ note.edit › NoteController@edit GET|HEAD sanctum/csrf-cookie .................................. sanctum.csrf-cookie › Laravel\Sanctum › CsrfCookieController@show 迅雷请求(同邮递员) JSON 请求 { "title": "Hello World", "content": "Lorem ipsum." } 尝试发出 JSON POST 请求并获取状态:405 方法不允许并且我正在使用 php artisan 服务,如果需要,我可以提供 GIT 项目。请告诉我。 您的验证规则看起来不正确。在您的 NoteRequest 类中,规则应该是一个关联数组,其中键是字段名称,值是验证规则。但是,在您的代码中,规则被定义为以逗号分隔的字符串列表。这可能会导致验证失败并返回 405 Method Not allowed 错误。 public function rules() { return [ 'title' => 'required|max:255|min:3', 'content' => 'nullable|max:255|min:10', ]; }


Laravel 动态扩展或使用 Traits

可以在运行时扩展或使用不同的类吗? 例子: 假设我们有一个名为 Player 的模型(我们的 A 模型) 可以在运行时扩展或使用不同的类吗? 示例: 假设我们有一个 model 称为 Player(我们的 A 模型) <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Player extends Model{ } 我们还有另外 2 个型号(B 和 C 型号) <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; protected $connection= 'db_b'; class PlayerInfoB extends Model{ function getName(){ return $this->name; } } 我们的C型号 <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; protected $connection= 'db_c'; class PlayerInfoC extends Model{ function getName(){ return $this->name_g; } } 模型A (Player)如何在运行时根据配置或其他数据扩展Model B or C 为什么我需要这个。 我有 2 个或更多不同的表,这些表的列有不同的名称,例如: Table 1 - name Table 2 - name_g Table 3 - name_full 所以我需要一个可以随时调用的包装器getName(),而无需检查现在使用的表。 $player = Player::get(); echo $player->getName(); 如果有不清楚的地方,请评论,我会更新我的问题。 更新基于madalin-ivascu答案可以这样完成吗? class Player extends Model{ protected $model; public function __construct(){ $this->setModel(); parent::__construct(); } protected function setModel(){ $this->model = $this->column_model_name } function getAttributeName(){ return $this->model->getName(); } } 如果不使用 eval 或 dirty hacks,就不可能在运行时编写一个类。您必须重新考虑您的类设计,因为您不太可能需要通过良好的设计来做到这一点。 您可以做的是使用方法 setTable 和 on: 在运行时更改模型实例上的表和数据库连接 Player::on('db_b')->setTable('player_info_b')->find($id); 另一种方法(首选)是定义模型 PlayerInfoC 和 PlayerInfoB 来扩展您的 Player 模型,然后根据您的情况在需要时实例化类 B 或 C。 在您的代码中,您的脚本必须具有您检查的状态,以便知道何时使用正确的模型? 既然如此,为什么不在 get name 中使用参数呢? class Player extends Model{ function getName($field){ return isset($this->{$field}) ? $this->{$field} : null; } } 如果你经常这样做,那么使用魔法方法: class Player extends Model{ function __get($key){ return isset($this->{$field}) ? $this->{$field} : null; } } ... echo $myModelInstance->{$field}; http://php.net/manual/en/language.oop5.overloading.php#object.get 在 Laravel 中,当你通过集合方法拉回数据时,它无论如何都会执行这个神奇的方法,因为所有属性都存储在称为属性的嵌套对象中,因此 __set() 和 __get() 看起来像这样: function __get($key){ return isset($this->attributes->{$key}) ? $this->attributes->{$key} : null; } function __set($key, $value){ return $this->attributes->{$key} = $value; } 建议后者带有属性子集,这样可以防止数据与返回的数据库列名称与模型中已使用的名称发生冲突。 这样,您只需在创建的每个模型中将一个属性名称作为保留名称进行管理,而不必担心您使用的数百个 var 名称会覆盖模型或模型扩展中的另一个属性名称。 使用该模型值来调用函数 $player = Player::get(); echo Player::getName($player->id,'PlayerInfoC'); 在 Player 模型中您只需调用 public static function getName($id,$class) return $class::where('player_id',$id)->getName();//each class will have the function } ps:您需要进行一些验证来测试该名称是否存在 另一种选择是在模型之间创建关系 您可以在模型中使用与以下相同的启动方法来执行此操作: protected static function booted() { if (<--your condition-- >) { $traitInitializers[static::class][] = 'boot' . ExampleTrait::class; $traitInitializers[static::class][] = 'boot' . Organizations::class; } }


Laravel 中的策略对我不起作用,这是我的代码

我无法让策略在我的 Laravel 项目中工作,我安装了一个新项目来从头开始测试,我有这个控制器: 我无法让策略在我的 Laravel 项目中工作,我安装了一个新项目来从头开始测试,我有这个控制器: <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\User; class UserController extends Controller { public function index() { $this->authorize('viewAny', auth()->user()); return response("Hello world"); } } 本政策: <?php namespace App\Policies; use Illuminate\Auth\Access\Response; use App\Models\User; class UserPolicy { public function viewAny(User $user): bool { return true; } } 这是我的模型 <?php namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'name', 'email', 'password', ]; /** * The attributes that should be hidden for serialization. * * @var array<int, string> */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array<string, string> */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } 我收到错误 403:此操作未经授权。我希望有人能帮助我解决我的问题。谢谢你 我也尝试过修改AuthServiceProvider文件,但没有任何改变。 必须在 App\Providers\AuthServiceProvider 中添加您的策略吗? protected $policies = [ User::class => UserPolicy::class ]; 您需要指定您正在使用的模型。具体来说,就是User。因此,传递当前登录的用户: $this->authorize('viewAny', auth()->user()); 此外,您正在尝试验证用户是否有权访问该页面。确保尝试访问该页面的人是用户,以便策略可以授权或不授权。 要在没有入门套件的情况下进行测试,请创建一个用户并使用它登录。 <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Auth; class UserController extends Controller { public function index() { $user = \App\Models\User::factory()->create(); Auth::login($user); $this->authorize('viewAny', auth()->user()); return response("Hello world"); } } 但是,如果您希望授予访客用户访问权限,您可以使用 ? 符号将 User 模型设为可选: public function viewAny(?User $user) { return true; }


© www.soinside.com 2019 - 2024. All rights reserved.