Question: My connection with the mongodb server gets established but I am unable to fetch any items from there.
This is a simple query to get all items from the User collection.

```
User.find({}, function (err, result) {
      if (err) {
        console.log(err);
      } else {
        res.json(result);
      }
    });

```

My `User` schema is very simple as well:

```
const mongoose = require("mongoose");

const userSchema = new mongoose.Schema({
  email: {
    type: String,
    required: true,
    minlength: 5,
    maxlength: 35,
  },
  password: {
    type: String,
    required: true,
    minlength: 5,
    maxlength: 100,
  },
  username: {
    type: String,
    required: true,
    minlength: 5,
    maxlength: 20,
  },
});

module.exports = {
  User: mongoose.model("user", userSchema),
};

```

What can I do?

Answer: 
If a variable is local, you need to `return` it so the caller can access it. Then you need to pass it as an argument for another method to access it.

```
    public static void Main() 
    {
        var item = RandomItem();   //Retrieve item 
        ViewItem(item);            //Then pass it in
    }

    public static Item RandomItem() {
        string randomPart1 ="";
        Item item1 = new Item(randomPart1);
        return item1;    //Return the item to Main
    }

    public static void ViewItem(Item item1) { //Accept item as argument from Main
        item1.PrintItem(); 
    }

```

There are other options-- for example, you could use a static variable-- but this is the most common way to do it.
You need to declare "item1" outsite of your "RandomItem()" method as a member of your "Program" class.

On a console App the entry point is a static method. So everything you declare in your "Program" class must be static.

```
class Program
{
    public static Item item1; // the static field that contains the instance of your "Item"
    public class Item
    {
        public string part1;

        public Item(string _part1)
        {
            part1 = _part1;
        }

        public void PrintItem()
        {
            Console.WriteLine(part1);
        }
    }
    public static void Main() 
    {
        RandomItem();
        ViewItem();
    }

    public static void RandomItem() {
        string randomPart1 ="";
        item1 = new Item(randomPart1);
    }
    public static void ViewItem() {
        item1.PrintItem();
    }
}   

```