Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
nodejs-60-2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nontawat kanboon
nodejs-60-2
Commits
c2628d35
Commit
c2628d35
authored
Feb 07, 2018
by
nontawat kanboon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete logic.js
parent
ccc4ca5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
39 deletions
+0
-39
logic.js
week04/contact-manager/logic.js
+0
-39
No files found.
week04/contact-manager/logic.js
deleted
100644 → 0
View file @
ccc4ca5c
let
lo
=
function
toLower
(
y
)
{
return
y
.
toLowerCase
();
}
//mongoose.assert=require
const
mongoose
=
require
(
'mongoose'
);
mongoose
.
Promise
=
global
.
Promise
;
const
db
=
mongoose
.
connect
(
'mongodb://localhost:27017/contactdb'
);
const
contactSchema
=
mongoose
.
Schema
({
firstname
:
{
type
:
String
,
set
:
toLower
},
lastname
:
{
type
:
String
,
set
:
toLower
},
phone
:
{
type
:
String
,
set
:
toLower
},
email
:
{
type
:
String
,
set
:
toLower
}
});
const
Contact
=
mongoose
.
model
(
'Contact'
,
contactSchema
);
const
addContact
=
(
contact
)
=>
{
console
.
info
(
'กำลังเพิ่มรายการติดต่อ ${contact}'
);
Contact
.
create
(
contact
,
(
err
)
=>
{
// assert.equal(null, err);
console
.
info
(
'เพิ่มรายการตืดต่อใหม่สำเร็จ'
);
db
.
disconnect
();
});
};
const
getContact
=
(
name
)
=>
{
const
search
=
new
RegExp
(
name
,
'i'
);
Contact
.
find
({
$or
:
[{
firstname
:
search
},
{
lastname
:
search
}]})
.
exec
((
err
,
contact
)
=>
{
//assert.equal(null, err);
console
.
info
(
contact
);
console
.
info
(
ค้นหาเจอทั้งหมด
$
{
contact
.
length
}
รายการ
);
db
.
disconnect
();
});
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment