2023-01-01から1年間の記事一覧

adminMongo で private subnet に設置した mongoDB からデータを取得する

環境: mongoDB を private subnet に設置 adminMongo を public subnet に設置 github.com @public subnet App instance cd projectDirectory git clone https://github.com/mrvautin/adminMongo.git && cd adminMongo cd adminMongo adminMongo/config/app…

sudo apt update でエラー:W: GPG error: https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6A26B1AE64C3C388 E: The repository 'https://repo.mongod

sudo apt update で下エラー W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release: The …

mongoDB: Upgrade した直後、mongod で DB がすぐにシャットダウンしてしまう

環境: mongoDB@4.2 から @6.0.6 にアップグレード error: This version of MongoDB is too recent to start up on the existing data files. Try MongoDB 4.2 or earlier solution: root ディレクトリの data フォルダを削除して再度dataフォルダを設置 ref…

jenssegers / laravel-mongodb ランダムなレコードを取得する

環境: Laravel@9.52.4 jenssegers/laravel-mongodb@3.9.5 $Posts = Post::raw(function($collection) { return $collection->aggregate([ ['$sample' => ['size' => 5]], ['$project' => ['title' => 1, 'body' => 1]] ]);}); ref: www.codegrepper.com gith…

Laravel: forPage() で page によって返値が配列になったりオブジェクトになったり

環境: Laravel@9.52.4 事象: Laravel でforPage() を使ってPagination を実装したがページによってオブジェクトが返ってくる。 ↓↓正常な挙動(配列が返る) ↓↓異常な挙動(オブジェクトが返る) ↑↑(indexがfilter()により抜けがある) solution) 同じロジックでp…

mongoDB の効率的なデータベース設計 ChatGPT曰く

>>> 頻繁に検索するならフラットに、そうでなくてかつデータの関連性を維持したいならネストもあり。 >>> 検索対象が小規模ならメンテナンスのことを考えてアプリケーション側の処理のしやすさを優先させてもいいかも。

Laravel: migration file を削除してしまい php artisan migrate:reset でエラー

環境: Laravel@9.52.4 migrate 済みの migration ファイルを削除してしまい、php artisan migrate:reset で Migration not found とエラーが出てしまった場合。 solution) php artisan migrate:fresh >>> DB全てのテーブルが削除された後、migrate する処理 …

php artisan db:seed >>> Target class [hoge] does not exists

seeder の namespace が間違っていた seeder を編集しても適用されない場合があるので編集したら composer dump-autoload

PHP マイナーアップグレード 8.0.x to 8.2

PHP

sudo add-apt-repository ppa:ondrej/php sudo apt show php インストールできるバージョンが表示される sudo apt-get update sudo apt-get install -y php ref: self-development.info