Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hdoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Stephane Crozat
hdoc
Commits
b2adb48b
Commit
b2adb48b
authored
Dec 31, 2016
by
Kapilraj Thangeswaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout fonction mise à jour et suppression
parent
c5c335c8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
15 deletions
+43
-15
hdoc_to_mongo/README.md
hdoc_to_mongo/README.md
+4
-6
hdoc_to_mongo/hdoc_to_mongo.ant
hdoc_to_mongo/hdoc_to_mongo.ant
+2
-2
hdoc_to_mongo/mongo/config.json
hdoc_to_mongo/mongo/config.json
+1
-1
hdoc_to_mongo/mongo/main.js
hdoc_to_mongo/mongo/main.js
+32
-6
hdoc_to_mongo/web/config.json
hdoc_to_mongo/web/config.json
+4
-0
hdoc_to_mongo/web/index.html
hdoc_to_mongo/web/index.html
+0
-0
hdoc_to_mongo/web/setup.bat
hdoc_to_mongo/web/setup.bat
+0
-0
hdoc_to_mongo/web/title.html
hdoc_to_mongo/web/title.html
+0
-0
No files found.
hdoc_to_mongo/README.md
View file @
b2adb48b
...
...
@@ -33,7 +33,7 @@ Use "config.json" in the "mongo" folder to specify :
-
database : the database you are using
-
collection : the collection you are using
-
request : the request you want to perform (for allowed requests, please check "Supported requests")
```
javascript
```
{
"url" : "mongodb://localhost:27017/",
"database" : "database",
...
...
@@ -44,13 +44,11 @@ Use "config.json" in the "mongo" folder to specify :
### In "web" folder
Use "config.json" in the "web" folder to specify :
-
url : mongodb's url
-
database : the database you are using
-
url : mongodb's url including the database
-
collection : the collection you are using
```
javascript
```
{
"
url
"
:
"
mongodb://localhost:27017/
"
,
"
database
"
:
"
database
"
,
"url" : "mongodb://localhost:27017/database",
"collection" : "collection",
}
```
...
...
hdoc_to_mongo/hdoc_to_mongo.ant
View file @
b2adb48b
<project name="hdoc_to_mongo" default="
insertion
">
<project name="hdoc_to_mongo" default="
mongoDB
">
<property file="build.properties"/>
...
...
@@ -55,7 +55,7 @@
<delete dir="${tmpdir}" />
</target>
<target name="
insertion
" depends="main">
<target name="
mongoDB
" depends="main">
<exec executable="node" dir="mongo">
<arg line="main.js"/>
</exec>
...
...
hdoc_to_mongo/mongo/config.json
View file @
b2adb48b
...
...
@@ -2,5 +2,5 @@
"url"
:
"mongodb://localhost:27017/"
,
"database"
:
"test"
,
"collection"
:
"nf29"
,
"request"
:
"
insert
"
"request"
:
"
update
"
}
\ No newline at end of file
hdoc_to_mongo/mongo/main.js
View file @
b2adb48b
...
...
@@ -11,20 +11,46 @@ if(url.slice(-1) == "/") {
}
const
outputFolder
=
"
../output
"
;
var
insertDocument
=
function
(
db
,
collection
,
json
,
callback
)
{
var
insertDocument
=
function
(
db
,
collection
,
json
)
{
db
.
collection
(
collection
).
insertOne
(
json
,
function
(
err
,
result
)
{
assert
.
equal
(
err
,
null
);
console
.
log
(
json
.
title
+
"
inserted into
"
+
collection
+
"
collection.
"
);
callback
();
});
assert
.
equal
(
err
,
null
);
console
.
log
(
json
.
title
+
"
inserted into
"
+
collection
+
"
collection.
"
);
});
};
var
updateDocument
=
function
(
db
,
collection
,
json
)
{
db
.
collection
(
collection
).
updateOne
({
"
title
"
:
json
.
title
},
json
,
function
(
err
,
result
)
{
assert
.
equal
(
err
,
null
);
if
(
result
.
result
.
n
>
0
)
{
console
.
log
(
json
.
title
+
"
updated.
"
);
}
else
{
console
.
log
(
json
.
title
+
"
not found.
"
);
}
});
};
var
removeDocument
=
function
(
db
,
collection
,
json
)
{
db
.
collection
(
collection
).
remove
({
"
title
"
:
json
.
title
},
function
(
err
,
result
)
{
assert
.
equal
(
err
,
null
);
if
(
result
.
result
.
n
>
0
)
{
console
.
log
(
json
.
title
+
"
removed.
"
);
}
else
{
console
.
log
(
json
.
title
+
"
not found.
"
);
}
});
};
MongoClient
.
connect
(
url
,
function
(
err
,
db
)
{
assert
.
equal
(
null
,
err
);
fs
.
readdir
(
outputFolder
,
(
err
,
files
)
=>
{
files
.
forEach
(
file
=>
{
var
json
=
JSON
.
parse
(
fs
.
readFileSync
(
outputFolder
+
"
/
"
+
file
));
if
(
config
.
request
===
'
insert
'
)
{
insertDocument
(
db
,
config
.
collection
,
JSON
.
parse
(
fs
.
readFileSync
(
outputFolder
+
"
/
"
+
file
)),
function
(){});
insertDocument
(
db
,
config
.
collection
,
json
);
}
else
if
(
config
.
request
===
'
update
'
)
{
updateDocument
(
db
,
config
.
collection
,
json
);
}
else
if
(
config
.
request
===
'
remove
'
)
{
removeDocument
(
db
,
config
.
collection
,
json
);
}
});
db
.
close
();
...
...
hdoc_to_mongo/
exemple
/config.json
→
hdoc_to_mongo/
web
/config.json
View file @
b2adb48b
{
"url"
:
"http://
172.25.31.252
:28017/test"
,
"url"
:
"http://
localhost
:28017/test"
,
"collection"
:
"nf29"
}
\ No newline at end of file
hdoc_to_mongo/
exemple
/index.html
→
hdoc_to_mongo/
web
/index.html
View file @
b2adb48b
File moved
hdoc_to_mongo/
exemple
/setup.bat
→
hdoc_to_mongo/
web
/setup.bat
View file @
b2adb48b
File moved
hdoc_to_mongo/
exemple
/title.html
→
hdoc_to_mongo/
web
/title.html
View file @
b2adb48b
File moved
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