Strange Error: The News_Feed collection does not exist.

This is really strange. I have a collection called News_Feed and I insert values into them as per the code mentioned below. This was running perfectly a couple of days back, but from last week there was no data that was inserted into this DB collection by the code mentioned below.
Reason which I got from logs -
Error: The News_Feed collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.

This is really strange as the DB is right in front of my eyes and there are other DBs as well that I refer to from the same page and they work seemingly fine.

Anyone who has faced this issue and can help me on this would be much appreciated.

My code:

import wixData from ‘wix-data’;
export function button21_click(event, $w) {
//Add your code for this event here:
let uri = $w(“#input15”).value;
let url = “http://xyz.site” + uri + “&xpath=/body”;
getNewsFeed(url)
.then(news => {

	let cnt = news.length; 
	let pcnt = 0; 
	while (pcnt !== cnt){ 
		$w("#text343").text = news[pcnt].text; 
		let totalcnt = $w("#text343").text.length; 
		let text = $w("#text343").text; 
		$w("#text343").text = text.replace('\n'," "); 
		text = $w("#text343").text; 
		
		
		//console.log(text); 
		let cntr = 0; 
		let prcnt = 0; 
		//let totalcnt1=text.length; 
		var category; 
		var subCategory;		 
		while (cntr < totalcnt+1){ 
			if(text.charAt(cntr) === " "  || cntr === totalcnt) 
				{ 
					
					let a = text.slice(prcnt, cntr).trim(); 
					prcnt = cntr; 
					//console.log(a); 
					
					let txt1 = a.replace("[",""); 
					a = txt1; 
					let txt2 = a.replace("]",""); 
					a = txt2; 
				
					let e = a.search("@"); //email 
					let f = a.search(/\b[A-Fa-f0-9]{64}\b/); //sha-256 
					//let g = a.search(/\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}\b/); //ipv4 
					let g = a.search(/\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b/); 
					let d = a.search(/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$/);//domain 
					let m = a.search(/\b[a-f0-9]{32}\b/); //md5 
					let u = a.search(/(?:(?:https?|ftp):\/\/|\b(?:[a-z\d]+\.))(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s!'()\[\]{};:'".,<>?«»“”‘’]))?/); 
					

					category = "None"; 
				
					if(e >0){ 
						category = "Email"; 
						subCategory = "Sender's Address"; 
					} 
					if(f >0){ 
						category = "File Hash"; 
						subCategory = "SHA-256"; 
						
					} 
					if(g >-1){ 
						category = "IP Address"; 
						subCategory = "IPv4"; 
						
					} 
					if(d>-1){ 
						category = "Domain / URL"; 
						subCategory = "Domain"; 
						
					} 
					if(u>0){ 
						category = "Domain / URL"; 
						subCategory = "URL"; 
						
					} 
					if(m>-1){ 
						category = "File Hash"; 
						subCategory = "MD5"; 
						
					} 
					
					if(category !== "None"){ 
						let description = subCategory + " associated with " + $w("#input16").value + " " + $w("#dropdown5").value; 

						let toInsert = { 
  							"title":        $w("#input16").value, 
  							"actualIoc":	a, 
  							"category": 	category, 
  							"subCategory": 	subCategory, 
  							"srn":			$w("#dropdown3").value, 
  							"month":		$w("#dropdown6").value, 
  							"malwareCategory": $w("#dropdown4").value, 
  							"malwareSubCategory": $w("#dropdown5").value, 
  							"url":			$w("#input15").value, 
  							"description":	description, 
						}; 
					
						wixData.insert("News_Feed", toInsert) / ***/ toInsert is perfect as per console.logs*** 
							.then( (results) => { 
								let item = results; //see item below 
								console.log(results); 
							}) 
							.catch( (err) => { 
								let errorMsg = err; 
								**console.log(errorMsg);** ***// this is where the error message is logged*** 

Error: The News_Feed collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor.
} );

					}	 

					cntr++; 
				} //end if 
			else{ 
				cntr++; 
				} 
		} // end cntr while 
		pcnt++; 
	}//end pcnt while 
});//end getnewsfeed

Super strange, this has to be checked by a Wix Code member.

Hi,
Please share your editor’s URL so we can inspect.

hi Or,

Is there a separate way I can share you the editor details, what I observed is that the editor URL opens up my website for all.
Or is it that I am doing something wrong?

any updates on this guys? i am having the same problem

Only authorised wix employees are able to open your editor.

I’m having the same issue with a store database.

Same problem when using this code sample for my store collection:

wixData.query("MyCollection")
  .find()
  .then( (results) => {
    console.log(results.items);
  } );

Any updates on this?

Don’t know if this is going to help anyone, but I have a database collection that I just started using. It has three (potentially) different identifiers:

  • property ID

  • settings “dataset name”

  • name listed under “Site Structure”
    If these are different, it looks like anything other than the name listed under “Site Structure” will return this error. That was my experience, at least. Hope it helps someone…

@beyondobediencetrain would it be possible for you to show an example of what you are talking about, does your code now works?

@kaymanbaby
What are you trying to do here, as when you add your dataset you call it a set name that you want it to be known as.
https://support.wix.com/en/article/adding-and-setting-up-a-dataset


You will see in the pic from the Wix Support page linked that the name of the dataset is shown under the dataset icon.

However, like all elements that you place into your Wix Editor, they will all have a id name that you can see on the top left of the element’s box or in the properties panel for any element that you click on.

For the dataset in this pic above, the dataset id name is #dataset1

If you connect your dataset to something in your Wix Editor like a repeater for example, then it will list all your datasets names as to how you named it when you created it.

However, when you come to need to use any dataset in your code, then you need to use the elements id name which is #dataset1 or whatever the element is called instead.

As shown in this picture below, the dataset itself has a element id name of #dataset5 and this needs to be entered into the code instead of the actual name of the dataset that the user used when they created it.

This is why the user had the red circles at the start of each line as it was indicating that they did not have a dataset on their page with the element id name of #Member-World-Views and it should be renamed as #dataset5 instead.

However, if you look at the Wix API reference for Wix Data API and the insert function.
https://www.wix.com/corvid/reference/wix-data.html#insert

Examples

Insert an item into a collection

import wixData from 'wix-data';

// ...

let toInsert = {
  "title":        "Mr.",
  "first_name":   "John",
  "last_name":    "Doe"
};

wixData.insert("myCollection", toInsert)
//See here that the actual name of the dataset is used and not the elements id name//
  .then( (results) => {
		let item = results; //see item below
	} )
	.catch( (err) => {
		let errorMsg = err;
	} );

/*  item is:
 *
 *  {
 *    "_id":          "rifk4nrk-dj4o-djhe-oidk-fnoqw4oiglk4i",
 *    "_owner":       "ffdkj9c2-df8g-f9ke-lk98-4kjhfr89keedb",
 *    "_createdDate": "2017-05-24T12:33:18.938Z",
 *    "_updatedDate": "2017-05-24T12:33:18.938Z",
 *    "title":        "Mr.",
 *    "first_name":   "John",
 *    "last_name":    "Doe"
 *  }
 */

Although, note again that if you use Wix Dataset API and the save function for example, then you will need to use the elements id name, like as shown in the pic above where the user has used code with the Wix Dataset API to make sure that the dataset is ready through dataset onReady function, sets the filter on the dataset through setFilter function and then sorts the filtered order with the sort function

Examples

Save the current item

$w("#myDataset").save()
  .then( (item) => {
    let fieldValue = item.fieldName;
  } )
  .catch( (err) => {
    let errMsg = err;
  } );

Finally, with regards to Wix apps like Stores, Members, Bookings, Blog, Events, Paid Plans and so on, then note that their datasets are named differently and have to be queried in code like…

wixData.query("Stores/Collections")
wixData.query("Members/PrivateMembersData")
wixData.query("Bookings/Services")
wixData.query("Blog/Posts")
wixData.query("Events/Events")
wixData.query("PaidPlans/Plans")

If you see the Wix Corvid support pages and look in the menu on the left hand side, you will be able to see all the Wix apps and their own collections within Corvid and what you can do with them by clicking on the needed Wix app and viewing each one.

It might be hard to get your head around it all to begin with, however as long as you use and follow carefully all the available code examples etc, then it should be easier once you get started and start working with it all.

@kaymanbaby Hi Kayman, I think whiskey probably gave a more thorough response than I could, but just to add the example you requested, the three different identifiers are circled in blue. And yes, the code does work now.

@beyondobediencetrain @givemeawhisky thank you, very informative … I will try it again and see what happens