unwind시 1st:0, last: -1 holding: { $arrayElemAt: [ “$holding”, 0 ] } { $unwind: { path: “$replies”, preserveNullAndEmptyArrays: true } }, { $project: { postID:1, content:1, commentID:1, userNo:1, replies : { $ifNull:[“$replies”, {} ]}, activity : { $ifNull:[“$activity”, { blind:0, rating:0, thumbUp:0, thumbDown:0 } ]}, myActivity : { $ifNull:[“$myActivity”, [{ blind:0, rating:0, thumbUp:0, thumbDown:0 }] ]}, replyActivity : { $ifNull:[“$replyActivity”, { blind:0, rating:0, thumbUp:0, thumbDown:0 } ]}, myReplyActivity : { $ifNull:[“$myReplyActivity”, [{ blind:0, rating:0, thumbUp:0, thumbDown:0 }] ]}, _id:0 } },
더보기v-data-table unselect
<v-data-table v-model=”selectedTime” :headers=”headersTime” :items=”itemsTime” :items-per-page=”itemsPerPage” :single-select=”singleSelect” item-key=”timeID” show-select fixed-header hide-default-footer height=”600″ :search=”searchTime” class=”elevation-1″ ...
더보기node TIPS
npm i –global –production windows-build-tools npm install nodemon –save nodemon app node변경시 자동으로 restart
더보기vue tips
v-file-input : fileUpload = [] <no-ssr> //—–> update table const objIndex = this.items.findIndex(obj => obj.code === this.form.code) if (objIndex >= 0) { this.items.splice(objIndex, 1, this.form) } else { this.items.push(this.form) } <template v-slot:item.keyword=”{ item }”> <span v-html=”rawHtml(item)”></span> </template> <template v-slot:item.actionLeft=”{ item }”> <v-icon small class=”mr-2″ @click=”clickLeft($event, item)” > edit </v-icon> </template> //—–> watch props: { athleteInfo: { type:Object, default () { return { } } } }, watch: { athleteInfo: { deep: true, // Object<array, json> 은 Vue가 내용이 변경되었다는 것을 알기위해 true를 사용해야함 immediate: true, // 페이지 로드 시 즉시 watch 실행 handler (newVal, oldVal) { //this.gridData = lodash.cloneDeep(newVal) console.log(“=============================”, newVal) } }, },
더보기[node.js] express.js 라우트 요청 객체(req), 응답 객체(res) 정리
요청 객체 (Request) 일반적으로 req나 request와 같은 변수로 명명함. 어차피 콜백에 전달되므로 마음대로 지어도 된다. 여기서는 req로 사용. Methods req.params : 이름 붙은 라우트 파라미터를 담는다. ex : app.get(’/:idx’, (req, res) => { res.send(req.params.idx); }); -> req.params(name) : 이름 붙은 라우트 파라미터나 GET, POST 파라미터를 담는다. 하지만 여러가지 혼란을 줄 수 ...
더보기regex
<내가 작성한 정규식> 1 2 3 4 5 6 7 8 9 // id 체크 정규식 : 숫자, 영문만 입력 가능 var regExpId = /^[0-9a-z]+$/; // 비밀번호 규칙 정규식 // : 숫자, 특문 각 1회 이상, 영문은 2개 이상 사용하여 8자리 이상 입력 var regExpPw = /(?=.*\d{1,50})(?=.*[~`!@#$%\^&*()-+=]{1,50})(?=.*[a-zA-Z]{2,50}).{8,50}$/; // 이메일주소 형식 체크 정규식 var regExpEm = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i; cs 아래는 자주 쓰이는 정규식 모음 출처 : http://seongilman.tistory.com/186 1. var passwordRules = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,16}$/; var password = ‘password1’; console.log(passwordRules .test(password)); 2. function checkPassword(id,password){ if(!/^[a-zA-Z0-9]{10,15}$/.test(password)){ alert(‘숫자와 영문자 조합으로 10~15자리를 사용해야 합니다.’); return false; } var checkNumber = password.search(/[0-9]/g); ...
더보기vue
watch: { // 라우트가 변경되면 메소드를 다시 호출됩니다. ‘$route’: ‘fetchData’ },
더보기동적 라우트 매칭 | Vue Router
watch: { ‘$route’ (to, from) { let urlParams = new URLSearchParams(window.location.search); let type = urlParams.get(‘type’); let groupNo = urlParams.get(‘groupNo’); let collectionNo = urlParams.get(‘collectionNo’); let params = { groupNo: groupNo, collectionNo: collectionNo, limit: 10 }; this.searchCollection(params); }, },
더보기정규식
정규식은 일반 문자(예: a에서 z)와 메타문자로 알려진 특수 문자로 구성된 문자열 패턴이다. 패턴은 문자열 본문을 검색할 때 일치하는 문자열을 설명한다. 정규식은 검색되는 문자열과 일치하는 문자 패턴을 찾는 템플릿의 역할을 한다. 일반적으로 볼 수 있는 몇 가지 정규식 예는 다음과 같다. 출력 공통 <scRIPT> var s,re; function showChar(){ sindex=s.search(re); slastIndex=RegExp.lastIndex; document.write(sindex+’~’+RegExp.lastIndex); document.write(‘ (‘+s.substring(sindex,slastIndex)+’)’); } </scRIPT> <scRIPT>var s,re; function showChar(){ ...
더보기c# TimeSpan
// timespan to datetime DateTime riderRecord = new DateTime() + record.riderRecord; DateTime riderRecordDifference = new DateTime() + record.riderRecordDifference; DateTime riderRecordSoFar = new DateTime() + record.riderRecordSoFar; // datetime to timespan TimeSpan CurrentTime = riderRecord.TimeOfDay;
더보기