{

  "event": "tennis",

  "teams": [

    {

      "name": "Red",

      "players": [

        { "name": "Kim", "age": 22 },

        { "name": "Lee", "age": 21 }

      ]

    },

    {

      "name": "Blue",

      "players": [

        { "name": "Park", "age": 23 },

        { "name": "Choi", "age": 19 }

      ]

    }

  ]

}


* 배열안에 들어있는 데이터 찾기 ('Blue' 팀 찾기)

db.game.find(

  { teams: { $elemMatch: { name: "Blue" } } },

  { _id: 0, "teams.$": 1 }

);

  결과>

{

  "teams": [

    {

      "name": "Blue",

      "players": [

        { "name": "Park", "age": 23 },

        { "name": "Choi", "age": 19 }

      ]

    }

  ]

}


* 배열안 배열에서 데이터 찾기 ('Park' 플레이어 찾기)

db.game.find(

  { teams: { $elemMatch: { players: { $elemMatch: { name: "Park" } } } } },

  { _id: 0, "teams.$": 1 }

);


Posted by jungtae17
,

* atomts-menus.cson 파일 수정

  - 디렉토리 : $HOME/.atom/packages/atom-typescript/menus


# See https://atom.io/docs/latest/creating-a-package#menus for more details

'menu': [

  {

    'label': 'Packages'

    'submenu': [

      'label': 'TypeScript'

      'submenu': [

        { 'label': 'Build', 'command': 'typescript:build' }

        { 'label': 'Go To Declaration', 'command': 'typescript:go-to-declaration' }

        { 'label': 'Create Tsconfig.json', 'command': 'typescript:create-tsconfig.json-project-file' }

      ]

    ]

  }

]


'Atom 에디터' 카테고리의 다른 글

유용한 Atom 패키지 (개인 취향)  (0) 2015.11.25
Posted by jungtae17
,

참고> http://naradesign.net/wp/2012/05/30/1823/


Posted by jungtae17
,
TypeScript


미니맵


툴바


기능 확장


테마


'Atom 에디터' 카테고리의 다른 글

tsconfig.json 파일을 생성하는 메뉴 추가하기  (0) 2015.12.01
Posted by jungtae17
,

var array = [2, 5, 9];


var key = 3;

console.log('\nData : ' + key);                                  // Data : 3

console.log(array.indexOf(key) + ' : ' + ~array.indexOf(key));   // -1 : 0

console.log(array.indexOf(key) + ' : ' + !~array.indexOf(key));  // -1 : true

console.log(array.indexOf(key) + ' : ' + !array.indexOf(key));   // -1 : false


key = 2;

console.log('\nData : ' + key);                                  // Data : 2

console.log(array.indexOf(key) + ' : ' + ~array.indexOf(key));   // 0 : -1

console.log(array.indexOf(key) + ' : ' + !~array.indexOf(key));  // 0 : false

console.log(array.indexOf(key) + ' : ' + !array.indexOf(key));   // 0 : true


key = 9;

console.log('\nData : ' + key);                                  // Data : 9

console.log(array.indexOf(key) + ' : ' + ~array.indexOf(key));   // 2 : -3

console.log(array.indexOf(key) + ' : ' + !~array.indexOf(key));  // 2 : false

console.log(array.indexOf(key) + ' : ' + !array.indexOf(key));   // 2 : false


'JavaScript' 카테고리의 다른 글

ES2015 에 대하여  (0) 2016.03.03
Promise 사용법  (0) 2015.12.21
Function 객체의 Methods 소개  (0) 2015.11.23
C#에서 JSON 변환하기  (0) 2015.11.19
비교 연산자(&&,||)를 이용한 변수 할당  (0) 2015.11.19
Posted by jungtae17
,

1. Function.prototype.apply()

  : 함수를 호출하는데 this 값을 지정된 객체로 대체하고 매개변수를 배열로 전달 한다.

apply([thisObj[,argArray]])


2. Function.prototype.call()

  : 함수를 호출하는데 this 값을 지정된 객체로 대체하고 매개변수를 순서대로 전달 한다.

call([thisObj[,arg1[,arg2[,..,argN]]]])


3. Function.prototype.bind()

  : this 값이 지정된 함수를 생성하며, 초기 매개 변수를 지정 할 수 있다.

function.bind(thisArg[,arg1[,arg2[,...,argN]]])


'JavaScript' 카테고리의 다른 글

ES2015 에 대하여  (0) 2016.03.03
Promise 사용법  (0) 2015.12.21
if문에서 Array.prototype.indexOf() 응용하기  (0) 2015.11.23
C#에서 JSON 변환하기  (0) 2015.11.19
비교 연산자(&&,||)를 이용한 변수 할당  (0) 2015.11.19
Posted by jungtae17
,

socket.io 공식 사이트

  : http://socket.io/



npm 모듈

1. socket.io

  : https://www.npmjs.com/package/socket.io

2. socket.io-redis

  : https://www.npmjs.com/package/socket.io-redis

3. socket.io-emitter

  : https://www.npmjs.com/package/socket.io-emitter


'Node.js > npm 모듈' 카테고리의 다른 글

유용한 npm 명령어  (0) 2016.09.26
Linux 에서 .NET Core 로 C# DLL 만들기  (0) 2016.08.25
npm 설치 중 'fetch failed' 오류 해결 방법  (0) 2015.12.16
npm 스크립트 사용하기  (0) 2015.12.07
Posted by jungtae17
,

public class Person

{

    public string Name { get; set; }

    public DateTime Birthday { get; set; }

}


Person person = new Person { Name = "Bob", Birthday = new DateTime (1987, 2, 2) };

string output = Newtonsoft.Json.JsonConvert.SerializeObject (person);

Console.WriteLine (output);

Console.WriteLine();


person = Newtonsoft.Json.JsonConvert.DeserializeObject<Person> (output);

Console.WriteLine ("{0} - {1}", person.Name, person.Birthday);


string json = @"{ Name: 'Bob', HairColor: 'Brown' }";

var bob = Newtonsoft.Json.Linq.JObject.Parse (json);


Console.WriteLine ("{0} with {1} hair", (string)bob["Name"], (string)bob["HairColor"]);


참고> https://components.xamarin.com/gettingstarted/json.net


'JavaScript' 카테고리의 다른 글

ES2015 에 대하여  (0) 2016.03.03
Promise 사용법  (0) 2015.12.21
if문에서 Array.prototype.indexOf() 응용하기  (0) 2015.11.23
Function 객체의 Methods 소개  (0) 2015.11.23
비교 연산자(&&,||)를 이용한 변수 할당  (0) 2015.11.19
Posted by jungtae17
,

var config = {

    Redis: {

        Host: 'LocalHost'

    }

}


//-------------------------------------------

var a = config.Redis;

var b = config.Chat;


console.dir(a);     // { Host: 'LocalHost' }

console.dir(b);     // undefined


//-------------------------------------------

var c = config.Redis || 'Redis';

var d = config.Chat  || 'Chat';


console.dir(c);     // { Host: 'LocalHost' }

console.dir(d);     // 'Chat'


//-------------------------------------------

var e = config.Redis && 'Redis';

var f = config.Chat  && 'Chat';


console.dir(e);     // 'Redis'

console.dir(f);     // undefined


//-------------------------------------------

var g = config.Redis && config.Redis.Host;

var h = config.Chat  && config.Chat.Port;


console.dir(g);     // 'LocalHost'

console.dir(h);     // undefined


//-------------------------------------------

var i = (config.Redis && config.Redis.Host) || 'google.com';

var j = (config.Chat  && config.Chat.Port)  || 80;


console.dir(i);     // 'LocalHost'

console.dir(j);     // 80


'JavaScript' 카테고리의 다른 글

ES2015 에 대하여  (0) 2016.03.03
Promise 사용법  (0) 2015.12.21
if문에서 Array.prototype.indexOf() 응용하기  (0) 2015.11.23
Function 객체의 Methods 소개  (0) 2015.11.23
C#에서 JSON 변환하기  (0) 2015.11.19
Posted by jungtae17
,

_io = require('socket.io')(port, { transports: ['polling', 'websocket'] });


참고> engine.io -> Server -> Methods -> constructor -> Options -> transports 옵션

 : https://github.com/socketio/engine.io#methods-1

Posted by jungtae17
,