How to check, could use `Meteor.userId()` or not on anywhere?

How to check, could I use Meteor.userId() on not clear place?

// Try
if(Meteor.userId && Meteor.userId()){
}

But get

Error: Meteor.userId can only be invoked in method calls or publications

Please help me

One is for server, the other one is for client: https://guide.meteor.com/accounts.html#userid-ddp - you don’t need to use both.

I would like check it on Server, but I still get the same

// Create timestamp behaviours
class AppCollection extends Mongo.Collection {
  // Current user
  _getUserId() {
    return Meteor.isServer && Meteor.userId()
  }
  
  insert(....)

Get error when fixture run on startup

Error: Meteor.userId can only be invoked in method calls or publications

Please help me

But it work fine when I logged in, and insert data from Form Input

I don’t understand how to use, please example

You need to explicitly add a userId parameter for your collection functions. Then inside the method calls or publications, you need to pass this.userId explicitly