Skip to main content

Command Palette

Search for a command to run...

How to add virtual function to Mongo Schema in NestJS

Published
β€’1 min read

The title is a mouthful but it is what it is. Just wanted to drop a short memo.

I was trying to figure out how to get the right format and here is the code. After defining the schema, at the end, you can add a virtual function like so.

 ExamMetaSchema.virtual('fullname').get(function () {
   return `${this.firstname} ${this.lastname}`;
 });

More from this blog

πŸš€ νŠœν† λ¦¬μ–Ό: 5λΆ„ λ§Œμ— 빈 ν™”λ©΄μ—μ„œ μ•± λ°°ν¬κΉŒμ§€ (ai μ—μ΄μ „νŠΈ μŠ€νƒ)

GitHub Codespaces λ₯Ό μ‚¬μš©ν•˜λ©΄ 둜컬 λ¨Έμ‹ μ—μ„œ μ•„λ¬΄λŸ° μ„€μΉ˜λ₯Ό ν•˜μ§€ μ•Šκ³ λ„ κ°œλ°œμ„ ν•  수 μžˆλ‹€λŠ” 것을 μ΅œκ·Όμ— μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 또, claude code λ₯Ό μ“°λ©΄ μ½”λ”© μ—μ΄μ „νŠΈκ°€ ν”„λ‘¬ν”„νŠΈμ— λ§žμΆ”μ–΄μ„œ νŒŒμΌμ„ 직접 생성/μˆ˜μ •ν•˜κ³  코딩을 ν•΄ μ€€λ‹€λŠ” 것을 μ•Œκ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. λ§Œμ•½ 이 두가지λ₯Ό κ²°ν•©ν•˜λ©΄ μ–΄λ–¨κΉŒ ν•˜λŠ” 생각이 λ“€μ–΄μ„œ 이 μŠ€νƒμ΄ μž‘λ™ν• μ§€ ν…ŒμŠ€νŠΈλ₯Ό ν•΄ λ³΄μ•˜μŠ΅λ‹ˆλ‹€. 개발자 κ²½ν—˜μ΄ λ„ˆλ¬΄ ν›Œλ₯­ν•˜κΈ° λ•Œλ¬Έμ—, ν•΄λ‹Ή 과정을 μ•„λž˜μ™€ 같이 μ •λ¦¬ν–ˆμŠ΅λ‹ˆ...

Jan 8, 20262 min read

κ³ μ • IP 둜 인터넷에 μ—°κ²°λœ ν™˜κ²½μ—μ„œ VMWare - Ubuntu 20.04 μ»¨ν…Œμ΄λ„ˆλ₯Ό 인터넷에 μ—°κ²°μ‹œν‚€

μ‚¬μš© ν™˜κ²½ : VMWare Fusion 12.2.4 ν˜„μž¬ κ³ μ • IP λ₯Ό 톡해 μ™ΈλΆ€λ‘œ 인터넷을 μ ‘μ†ν•˜λŠ” λ„€νŠΈμ›Œν¬ ν™˜κ²½μž…λ‹ˆλ‹€. 이 λ•Œμ— VMWare 둜 Ubuntu 20.04 이미지λ₯Ό μ„€μΉ˜ν•˜λ‹ˆ λ°”λ‘œ 인터넷 연결이 λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€. 이럴 λ•Œμ— 인터넷 연결을 ν•˜λŠ” λ°©λ²•μž…λ‹ˆλ‹€. (Credit: https://www.youtube.com/watch?v=69jZUccRbik) VM instance 의 Network Adaptor λ₯Ό NAT 둜 μ„€μ •ν•©λ‹ˆλ‹€....

Nov 4, 20222 min read

Andrew Kim's Blog

18 posts