You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+283
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,11 @@ $ cd <project-name>
6
6
$ yarn install
7
7
```
8
8
9
+
Install `mocha`:
10
+
```bash
11
+
$ sudo yarn global add mocha
12
+
```
13
+
9
14
# Run
10
15
Make sure you have typescript installed, then run:
11
16
@@ -20,3 +25,281 @@ yarn test
20
25
21
26
# Database
22
27
When you first run this project, it will connect to a remote MongoDB instance I have setup so this project can be run with minimal overhead. However, I advise you to create your own `<project>/properties/local.properties.json` and `<project>/properties/test.properties.json`, since the remote mongo instance is cleaned on a regular basis.
28
+
29
+
30
+
----------------------------
31
+
32
+
# Create MongoDB database and account user
33
+
34
+
## MongoDB Connection
35
+
36
+
Check db server:
37
+
```bash
38
+
$ service mongod status
39
+
```
40
+
41
+
Run db server:
42
+
```bash
43
+
$ sudo service mongod start
44
+
45
+
$ service mongod status
46
+
...
47
+
Active: active (running)
48
+
```
49
+
50
+
[Getting Started with the mongo Shell](https://docs.mongodb.com/v3.0/tutorial/getting-started-with-the-mongo-shell/)
51
+
52
+
Start the mongo Shell:
53
+
```bash
54
+
$ mongo
55
+
56
+
// To display the database you are using:
57
+
$ MongoDB> db
58
+
test
59
+
60
+
// Print help
61
+
$ MongoDB>help
62
+
63
+
// Exit mongo shell
64
+
$ MongoDB>exit
65
+
$
66
+
```
67
+
> ```bash
68
+
>db.help() help on db methods
69
+
>db.mycoll.help() help on collection methods
70
+
>sh.help() sharding helpers
71
+
>rs.help() replica set helpers
72
+
>help admin administrative help
73
+
>help connect connecting to a db help
74
+
>help keys key shortcuts
75
+
>help misc misc things to know
76
+
>help mr mapreduce
77
+
>
78
+
> show dbs show database names
79
+
> show collections show collections in current database
80
+
> show users show users in current database
81
+
> show profile show most recent system.profile entries with time>= 1ms
82
+
> show logs show the accessible logger names
83
+
> show log [name] prints out the last segment of log in memory, 'global' is > default
84
+
> use <db_name>set current database
85
+
>db.foo.find() list objects in collection foo
86
+
> db.foo.find( { a : 1 } ) list objects in foo where a == 1
87
+
> it result of the last line evaluated; use to further iterate
88
+
> DBQuery.shellBatchSize = x set default number of items to display on shell
> That will create a new collection called “`teams`”, and save an object with two fields “`Country`” and “`GroupName`”. Crucially, this will now also save our database.
142
+
> Check that it has been created by running `show dbs` again.
The following operation creates ***`mongoUser`***in the ***`ts-mean-test`*** database and gives the user the `readWrite` and `dbAdmin` roles.
175
+
```bash
176
+
mongo> use ts-mean-test
177
+
>
178
+
> db.createUser(
179
+
{
180
+
user: "mongoUser",
181
+
pwd: "password",
182
+
roles: [ "readWrite", "dbAdmin" ]
183
+
}
184
+
)
185
+
186
+
>
187
+
>
188
+
```
189
+
190
+
Show the account users of `ts-mean-test` database:
191
+
```bash
192
+
mongo> use ts-mean-test
193
+
>
194
+
> show users
195
+
196
+
{
197
+
"_id" : "ts-mean-test.mongoUser",
198
+
"user" : "mongoUser",
199
+
"db" : "ts-mean-test",
200
+
"roles" : [
201
+
{
202
+
"role" : "readWrite",
203
+
"db" : "ts-mean-test"
204
+
},
205
+
{
206
+
"role" : "dbAdmin",
207
+
"db" : "ts-mean-test"
208
+
}
209
+
]
210
+
}
211
+
212
+
>
213
+
>exit
214
+
$
215
+
```
216
+
217
+
Connect `ts-mean-test` database with `mongoUser` account:
218
+
```bash
219
+
$ mongo ts-mean-test -u mongoUser -p
220
+
Enter password:
221
+
222
+
mongo> db
223
+
224
+
ts-mean-test
225
+
>
226
+
>
227
+
```
228
+
229
+
230
+
----------------------------
231
+
232
+
233
+
# DefinitelyTyped for TypeScript
234
+
235
+
## TypeScript 2.x
236
+
237
+
If you are using TypeScript 2.x you no longer need to have Typings or Definitely Typed installed. Simply install the following package.
238
+
```bash
239
+
$ yarn add @types/node --dev
240
+
or
241
+
$ npm install @types/node --save-dev
242
+
```
243
+
244
+
> OPTIONAL: If you are specifying typeroots or types in your tsconfig.json. You may need to update the tsconfig.json to include node as a type. By default any package under @types is already included in your build unless you've specified either of these options.
245
+
246
+
Below is proper configuration for each of these options:
247
+
`tsconfig.js`
248
+
```json
249
+
{
250
+
"compilerOptions": {
251
+
// types option has been previously configured
252
+
"types": [
253
+
// add node as an option
254
+
"node"
255
+
],
256
+
// typeRoots option has been previously configured
257
+
"typeRoots": [
258
+
// add path to @types
259
+
"node_modules/@types"
260
+
]
261
+
}
262
+
}
263
+
```
264
+
265
+
## TypeScript 1.x
266
+
267
+
The definitive step-by-step guide to use DefinitelyTyped typings for applications written in TypeScript. - Posted on 2016/06/20
0 commit comments