mongoDB(6)
-
Expressions with $project
db.movies.aggregate([ { $match: { cast: { $elemMatch: { $exists: true } }, directors: { $elemMatch: { $exists: true } }, writers: { $elemMatch: { $exists: true } } } }, { $project: { _id: 0, cast: 1, directors: 1, writers: { $map: { input: "$writers", as: "writer", in: { $arrayElemAt: [ { $split: ["$$writer", " ("] }, 0 ] } } } } }, { $project: { labor_of_love: { $gt: [ { $size: { $setIntersecti..
2021.02.04 -
Chapter 1: Basic Aggregation - $match and $project
Shaping documents with $project The correct answers are the following: Once we specify a field to retain or perform some computation in a $project stage, we must specify all fields we wish to retain. The only exception to this is the _id field. $project implicitly removes all other fields once we have retained, reshaped, or computed a new field. The exception to this is the _id field, which we m..
2021.02.03 -
[MongoDB University] 정리
파이프라인 : $match(일치모양골라내기) -> $project(형태변형) -> $group(단일파일로만들어전체에대한비율계산) Stages cannot be configured to produce our desired output. This is definitely not correct. Stages can be configured in almost any way we desire. Pipelines must consist of at least two stages. This is not correct. Pipelines must consist of at least one stage, and can have many stages. Documents flow through the pipeline, pass..
2021.02.01 -
[Mongoose] db.~.find() VS db.~.findOne()
결과 쿼리 비교 상황 find : 여러 {} 객체로 이루어진 [] 배열을 반환 findOne : 하나의 {} 객체를 반환 파라미터로 조건 쿼리가 없을 때 모든 Document들을 반환 모든 Document들 중 가장 첫 번째만 반환 파라미터로 조건 쿼리가 있으며, 해당 조건을 만족하는 Document가 여러 개 조건을 만족하는 Document를 반환 조건을 만족하는 Document 중 가장 첫번째만 반환 파라미터로 조건 쿼리가 있지만, 해당 조건을 만족하는 Document가 0개일 때 아무 일도 일어나지 않음 null 반환
2020.05.13 -
[MongoDB] CRUD (SQL과 비교하기)
use 파일명 MongoDB SQL 테이블들을 저장하는 파일 불러오기 use languages 해당 프로그램에 따라 GUI 또는 명령어 입력 db.콜렉션명.insertOne({필드명1: 필드값1, ...}) MongoDB SQL 기존에 없던 테이블 자체를 새로 추가 시 db.webdev.insertOne({_id:2, name:"javascript", category:"script"}) CREATE TABLE webdev ( id INT NOT NULL, name STRING, category STRING, PRIMARY KEY (id) ) 기존에 있는 테이블에 새 레코드 추가 시 INSERT INTO webdev VALUES (2, "javascript", "script") db.콜렉션명.find(레코..
2020.05.13 -
[Mongo DB] Install Manually on Mac OS(비추) => Home Brew로 가세요
1. 아래 링크에서 다운로드 받는다. https://www.mongodb.com/download-center/community Download Center: Community Server Download MongoDB Community Server, the most popular non-relational database built to address the needs of modern applications. www.mongodb.com 2. 압축을 해제한다. 3. 터미널을 켠다. 4. 터미널에서 아래 명령어를 입력하여 다운받아 압축해제한 폴더를 /usr/local/mongodb 경로로 옮긴다. sudo mv [현재 압축해제한 그 폴더를 여기에 드래그앤드롭하고 한칸 띄우기 ->] /usr/local/m..
2020.05.12