我有以下JSON
字符串,
{"card_id" : 75893645814809,"cust_id": 1008,"card_info": {"card_type" : "Travel Card","credit_limit": 126839},"card_dates" : [{"date":"1997-09-09" },{"date":"2007-09-07" }]}
我希望将其插入MongoDB
。任何人都可以帮助我。
提前致谢
答案 0 :(得分:0)
使用Casbah非常容易。这对我有用。请注意,不需要使用缓冲区,但如果您插入大量对象,则批量发送将大大提高性能。
<button ng-click="deleteCompany(company.id)"
class="btn btn-danger"
onClick="return window.confirm('This will permernently delete the entity\n
Are you sure you want to delete this post?'); ">
<span class="glyphicon glyphicon-trash"></span>
</button>
答案 1 :(得分:0)
例如:
val mongo_url = MongoClientURI("mongo://...")
val mongoClient: MongoClient = MongoClient(mongo_url)
val db = mongoClient("radar")
val coll = db("job_history")
val job = MongoDBObject("name"-> spark, "status"-> "success")
coll.insert(job)
coll.find().foreach(println)
输出将是这样的:
{&#34; _id&#34; :{&#34; $ oid&#34; :&#34; 5984b745a63eeeacbcbd301d&#34;},&#34; id&#34; :22,&#34;名称&#34; :&#34; shenrf22&#34;}