我试图编写一个有角度的应用程序,将来自全接触式API的信息作为json并将其插入到mongodb中。我可以成功获取json文件,但是当我尝试将其插入到mongodb中时,我遇到了各种错误。我解决了许多错误,但我卡在这一个。任何帮助表示赞赏。
ERROR:
MongoError {name: "MongoError", message: "docs parameter must be an array of documents", driver: true, stack: "MongoError: docs parameter must be an array of doc…(http://localhost:4200/vendor.bundle.js:71114:10)"}driver: truemessage: "docs parameter must be an array of documents"name: "MongoError"stack: "MongoError: docs parameter must be an array of documents? at Function.webpackJsonp.../../../../mongodb-core/lib/error.js.MongoError.create (http://localhost:4200/vendor.bundle.js:33916:11)? at Collection.webpackJsonp.../../../../mongodb/lib/collection.js.Collection.insertMany (http://localhost:4200/vendor.bundle.js:44864:32)? at http://localhost:4200/main.bundle.js:57:20? at Db.webpackJsonp.../../../../mongodb/lib/db.js.Db.collection (http://localhost:4200/vendor.bundle.js:49750:20)? at Object.webpackJsonp.../../../../../routes/kisiler.js.exports.kisiEkle (http://localhost:4200/main.bundle.js:54:9)? at http://localhost:4200/main.bundle.js:366:18? at Request.requested [as _callback] (http://localhost:4200/vendor.bundle.js:21598:5)? at Request.self.callback (http://localhost:4200/vendor.bundle.js:70137:22)? at Request.webpackJsonp.../../../../events/events.js.EventEmitter.emit (http://localhost:4200/vendor.bundle.js:20324:17)? at Request.<anonymous> (http://localhost:4200/vendor.bundle.js:71114:10)"__proto__: Error
at Object.../../../../mongodb-core/lib/error.js (http://localhost:4200/vendor.bundle.js:33927:24)
at …Run Code Online (Sandbox Code Playgroud) 这是我收到的错误消息:
ContactsWithPN - start loop
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
Run Code Online (Sandbox Code Playgroud)
以下是导致此问题的代码:
+(NSArray *) contactsWithPhoneNumbers{
NSArray *contacts = [ABContactsHelper contacts];
NSMutableArray *rv = [[NSMutableArray alloc] init];
NSLog(@"ContactsWithPN - start loop");
for (int i = 0; i< [contacts count] ; i++) {
ABContact * c = (ABContact*)[contacts objectAtIndex:i];
ABContact * fullContact = [ABContact contactWithRecordID:[c recordID]];
if ([[fullContact phoneArray] count] > 0) {
[rv addObject:fullContact];
}
}
NSLog(@"ContactsWithPN - …Run Code Online (Sandbox Code Playgroud)