Skip to content

Commit fd459b0

Browse files
author
Josh Smith
committed
Added my code to the shared repo
1 parent 37b74a6 commit fd459b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2611
-1
lines changed

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
# mongodb-sprint-zero
1+
# MS0
2+
Set of code assets for SA's to use when deliverying an MSO.
3+
4+
## Demo Purposes Only
5+
The code contained in this repository is intended simply to help boostrap the MongoDB Spring Zero process. The code works. but is **NOT PRODUCTION READY** and is not intended to be.
6+
7+
MongoDB Sprint Zero is about helping your customers
8+
- Quickly start consuming credits
9+
- Be able to maintain momentum in their development and buying process
10+
- Help them have something to demonstrate the value at the end of the Sprint
11+
12+
By creating code assets in the customer native language, we are able to accelerate past some of those bootstrap concepts and get the developers working directly with the data in a meaningful way which will increase their knowledge, likelihood of success, and stickiness factor with MongoDB.
13+
14+
## How to Use
15+
16+
1. Clone the Repo down to your local machine
17+
2. Identify which sample project is the best fit for your client
18+
3. Make any necessary pro-active changes. This includes potentially
19+
- Adding in customer business objects based on your clients needs
20+
- CSFLE configuration if that's critical for your customer
21+
- Creating new sample data records
22+
5. Zip up the resulting folders to be able to share with the customer
23+
24+
***Note: The contents of this repo should not be shared directly with the customer. We want to be able to correctly share the caveats above when we present this to customers.***
25+
26+
27+
28+
## Organization
29+
30+
At the top level you have shared assets, including
31+
32+
- [``` sample-data ```](sample_data/README.md) folder that contains some mgenerate compliant JSON scripts for creating fake customers
33+
- [``` java-sample ```](java-sample/README.md) - Java project that uses the native MongoDB Java Driver to connect
34+
- [``` spring-data ```](spring-data/README.md) - Java project using the Spring-boot and Spring-data packages to access the DB
35+
- [``` dotnet-sample ```](dotnet-sample/README.md) - C# and .Net CORE webapi that connects to the DB using the native MongoDB driver
36+
37+
38+
39+
All of the project use essentially the same concept.
40+
41+
### Project Structure
42+
43+
#### Controller
44+
Some level of Controller class that exposes a REST API for @ ``` /customer ``` for the teams to access via a tool like Postman. This isn't directly related to the DB, but does make the entire project feel more real and will simplify their work to create a demonstrable prototype.
45+
46+
#### Service
47+
A package for service classes that can contain any business logic that the cusotmer would perform. This is merely there to try to show some best practices for how to create a project.
48+
49+
#### DAO / Repository
50+
This layer can have multiple names, but represents the data access layer of the project. .Net and Spring-Data will tend to use the repository pattern.
51+
52+
53+
### Content
54+
55+
Each project use the same example for a Customer object. This allows you to take the same sample-data and reuse it in any concept.
56+
57+
The intent is to create a simple object that can start to demonstrate the benefits of the document model. If your customer gave you specific business objects that they want to use, then replace the default Customer object with the ones provided by your customer. Their objects should always take precedence.
58+
59+
The default is simply there to give you a fully connected starting place with working examples of a query, an insert, and an aggregation query.
60+
61+

dotnet-sample/.gitignore

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/dotnetcore,intellij,visualstudiocode
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=dotnetcore,intellij,visualstudiocode
3+
4+
### DotnetCore ###
5+
# .NET Core build folders
6+
bin/
7+
obj/
8+
9+
# Common node modules locations
10+
/node_modules
11+
/wwwroot/node_modules
12+
13+
### Intellij ###
14+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
15+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
16+
17+
# User-specific stuff
18+
.idea/**/workspace.xml
19+
.idea/**/tasks.xml
20+
.idea/**/usage.statistics.xml
21+
.idea/**/dictionaries
22+
.idea/**/shelf
23+
24+
# AWS User-specific
25+
.idea/**/aws.xml
26+
27+
# Generated files
28+
.idea/**/contentModel.xml
29+
30+
# Sensitive or high-churn files
31+
.idea/**/dataSources/
32+
.idea/**/dataSources.ids
33+
.idea/**/dataSources.local.xml
34+
.idea/**/sqlDataSources.xml
35+
.idea/**/dynamic.xml
36+
.idea/**/uiDesigner.xml
37+
.idea/**/dbnavigator.xml
38+
39+
# Gradle
40+
.idea/**/gradle.xml
41+
.idea/**/libraries
42+
43+
# Gradle and Maven with auto-import
44+
# When using Gradle or Maven with auto-import, you should exclude module files,
45+
# since they will be recreated, and may cause churn. Uncomment if using
46+
# auto-import.
47+
# .idea/artifacts
48+
# .idea/compiler.xml
49+
# .idea/jarRepositories.xml
50+
# .idea/modules.xml
51+
# .idea/*.iml
52+
# .idea/modules
53+
# *.iml
54+
# *.ipr
55+
56+
# CMake
57+
cmake-build-*/
58+
59+
# Mongo Explorer plugin
60+
.idea/**/mongoSettings.xml
61+
62+
# File-based project format
63+
*.iws
64+
65+
# IntelliJ
66+
out/
67+
68+
# mpeltonen/sbt-idea plugin
69+
.idea_modules/
70+
71+
# JIRA plugin
72+
atlassian-ide-plugin.xml
73+
74+
# Cursive Clojure plugin
75+
.idea/replstate.xml
76+
77+
# SonarLint plugin
78+
.idea/sonarlint/
79+
80+
# Crashlytics plugin (for Android Studio and IntelliJ)
81+
com_crashlytics_export_strings.xml
82+
crashlytics.properties
83+
crashlytics-build.properties
84+
fabric.properties
85+
86+
# Editor-based Rest Client
87+
.idea/httpRequests
88+
89+
# Android studio 3.1+ serialized cache file
90+
.idea/caches/build_file_checksums.ser
91+
92+
### Intellij Patch ###
93+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
94+
95+
# *.iml
96+
# modules.xml
97+
# .idea/misc.xml
98+
# *.ipr
99+
100+
# Sonarlint plugin
101+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
102+
.idea/**/sonarlint/
103+
104+
# SonarQube Plugin
105+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
106+
.idea/**/sonarIssues.xml
107+
108+
# Markdown Navigator plugin
109+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
110+
.idea/**/markdown-navigator.xml
111+
.idea/**/markdown-navigator-enh.xml
112+
.idea/**/markdown-navigator/
113+
114+
# Cache file creation bug
115+
# See https://youtrack.jetbrains.com/issue/JBR-2257
116+
.idea/$CACHE_FILE$
117+
118+
# CodeStream plugin
119+
# https://plugins.jetbrains.com/plugin/12206-codestream
120+
.idea/codestream.xml
121+
122+
# Azure Toolkit for IntelliJ plugin
123+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
124+
.idea/**/azureSettings.xml
125+
126+
### VisualStudioCode ###
127+
.vscode/*
128+
!.vscode/settings.json
129+
!.vscode/tasks.json
130+
!.vscode/launch.json
131+
!.vscode/extensions.json
132+
!.vscode/*.code-snippets
133+
134+
# Local History for Visual Studio Code
135+
.history/
136+
137+
# Built Visual Studio Code Extensions
138+
*.vsix
139+
140+
### VisualStudioCode Patch ###
141+
# Ignore all local history of files
142+
.history
143+
.ionide
144+
145+
# End of https://www.toptal.com/developers/gitignore/api/dotnetcore,intellij,visualstudiocode

dotnet-sample/.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/.idea.dotnet-sample.dir/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/.idea.dotnet-sample.dir/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/.idea.dotnet-sample.dir/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/.idea.dotnet-sample.dir/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/dotnet-sample.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/jpa-buddy.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dotnet-sample/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace dotnet_sample.Configuration;
2+
3+
public class MS0DatabaseSettings
4+
{
5+
public string ConnectionString { get; set; } = null;
6+
public string DatabaseName { get; set; } = null;
7+
public string CustomerCollectionName { get; set; } = null;
8+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using MongoDB.Driver;
2+
3+
namespace dotnet_sample.Configuration;
4+
5+
public class MongoDBClient
6+
{
7+
8+
private IMongoClient client;
9+
10+
public MongoDBClient()
11+
{
12+
this.client = new MongoClient("mongodb://localhost:27017");
13+
}
14+
15+
public IMongoClient GetClient()
16+
{
17+
return this.client;
18+
}
19+
20+
21+
22+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using dotnet_sample.Services;
2+
using Microsoft.AspNetCore.Mvc;
3+
4+
namespace dotnet_sample.Controllers;
5+
6+
[ApiController]
7+
[Route("customer")]
8+
public class CustomerController : ControllerBase
9+
{
10+
private readonly ILogger<CustomerController> _logger;
11+
private CustomerService service;
12+
13+
public CustomerController(ILogger<CustomerController> logger, CustomerService service)
14+
{
15+
_logger = logger;
16+
this.service = service;
17+
}
18+
19+
[HttpGet]
20+
public List<Customer> Get()
21+
{
22+
return this.service.GetAllCustomers();
23+
}
24+
25+
26+
[HttpGet("{id}")]
27+
public Customer Get(string id)
28+
{
29+
return this.service.GetById(id);
30+
}
31+
32+
[HttpPost]
33+
public Customer Create([FromBody] Customer customer)
34+
{
35+
return this.service.CreateCustomer(customer);
36+
}
37+
38+
[HttpPost("search")]
39+
public List<Customer> CustomerSearch([FromBody] Dictionary<String, String> request)
40+
{
41+
String name = request.GetValueOrDefault("name");
42+
Console.WriteLine(name);
43+
44+
return this.service.CustomerSearch(name);
45+
}
46+
47+
48+
}

dotnet-sample/Models/Address.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace dotnet_sample;
2+
3+
public class Address
4+
{
5+
public string city { get; set; }
6+
public string state { get; set; }
7+
public string country { get; set; }
8+
public string street { get; set; }
9+
}

0 commit comments

Comments
 (0)